Is str ~ regex the root of all evil, or the leaf of all good?
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Thu Feb 19 08:05:54 PST 2009
Jarrett Billingsley wrote:
> On Thu, Feb 19, 2009 at 10:01 AM, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org> wrote:
>
>>> RE attributes:
>>> "repeat", "r": Repeat over the whole input string
>>> "ignorecase", "i": case insensitive
>>> "multiline", "m": treat as multiple lines separated by newlines
>>> "verbose", "v": ignores space outside [] and allows comments
>> And how do you combine them? "repeat, ignorecase"? Writing and parsing such
>> options becomes a little adventure in itself. I think the "g", "i", and "m"
>> flags are popular enough if you've done any amount of regex programming. If
>> not, you'll look up the manual regardless.
>
> While we're on the subject I'd like to mention that an unbelievably
> overwhelming proportion of the time, when I use regexen, I want them
> to be global. As in, I don't think I've ever used a non-global regex.
>
> To that effect I'd like to propose that either "g" be the default
> attribute, or that it should be on _unless_ some other attribute ("o"
> for once?) is present. I think this is one thing that Perl got
> terribly wrong.
Well I agree for searches but not for substitutions.
In D searches, the lazy way of matching means you can always go with "g"
and change your mind whenever you please. I think I'll simply eliminate
"g" from the offered options for search.
Andrei
More information about the Digitalmars-d
mailing list