[Issue 7260] "g" on default in std.regex
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jan 25 12:22:48 PST 2013
http://d.puremagic.com/issues/show_bug.cgi?id=7260
--- Comment #5 from Dmitry Olshansky <dmitry.olsh at gmail.com> 2013-01-25 12:22:46 PST ---
(In reply to comment #4)
> If changing std.regex.regex is not possible, then an alternative solution is to
> introduce the new little function "std.regex.re", that repeats on default, that
> is like:
>
> re(someString) === regex(someString, "g")
>
> re(someString, "d") === regex(someString, "dg")
Frankly this is stupid (sorry). Obviously the wrong turn is that people
(rightfully so) associate "find all" vs "find first" with operation that is
"match"/"replace" not the "regex" as in the pattern itself.
Personally I think that we better go with explicit overrides on
"match"/"replace"/etc. and very slowly deprecate the "g" switch.
Then how the override will look like is up for debate.
match(someString, pattern).all //range of all matches
match(someString, pattern).first //only the first one
match(someString, pattern) // using the "g" flag to decide
Or pass the override as optional parameter to match:
match(someString, pattern, Regex.all);
match(someString, pattern, Regex.first);
match(someString, pattern); //use the flag
I'll probably open a poll to pick the better one.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list