www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - simple "find" question

reply "WhatMeWorry" <kc_heaser yahoo.com> writes:
I get a comiler error for some older code which uses regexp.find

if (std.regexp.find(pText, lMacro.Pattern, "m") != -1)

Ok. So I look at the phobos docs and find:

deprecated sizediff_t find(string s, string pattern, string
attributes = null); Returns:

Same as find(s, RegExp(pattern, attributes)).

WARNING:
    This function is scheduled for deprecation due to unnecessary
ambiguity with the homonym function in std.string. Instead of
std.regexp.find(s, p, a), you may want to use find(s, RegExp(p,
a)).

But I can't find "find(s, RegExp(p, a))".  There is an entry in
std.algorithm but does a haystack and needle coorespond to a
string and regular expression.

And std.regex talks about "matches" and stuff but is this
equivalent to "find".
May 07 2012
next sibling parent "WhatMeWorry" <kc_heaser yahoo.com> writes:
On Monday, 7 May 2012 at 19:45:36 UTC, WhatMeWorry wrote:
 I get a comiler error for some older code which uses regexp.find

 if (std.regexp.find(pText, lMacro.Pattern, "m") != -1)

 Ok. So I look at the phobos docs and find:

 deprecated sizediff_t find(string s, string pattern, string
 attributes = null); Returns:

 Same as find(s, RegExp(pattern, attributes)).

 WARNING:
    This function is scheduled for deprecation due to unnecessary
 ambiguity with the homonym function in std.string. Instead of
 std.regexp.find(s, p, a), you may want to use find(s, RegExp(p,
 a)).

 But I can't find "find(s, RegExp(p, a))".  There is an entry in
 std.algorithm but does a haystack and needle coorespond to a
 string and regular expression.

 And std.regex talks about "matches" and stuff but is this
 equivalent to "find".

Think I found it. CountUntil gives me a index. assert(countUntil("hello world", "world") == 6); Will study more, and post less.
May 07 2012
prev sibling parent "Jesse Phillips" <jessekphillips+D gmail.com> writes:
On Monday, 7 May 2012 at 19:45:36 UTC, WhatMeWorry wrote:

 And std.regex talks about "matches" and stuff but is this
 equivalent to "find".

The warning was talking about the find in std.regexp which is right above that function. You want std.regex.match. Sorry got to go.
May 08 2012