www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Regex Non-capturing and Named Groups.

reply AJG <AJG_member pathlink.com> writes:
Hi there,

First off, why are D's regexes called RegExp? Most languages I've come across
use Regex. I know it's only one letter, but I make this mistake a lot.

Second, is there support in the library for non-capturing groups and/or named
groups?

Usually, for a non-capturing group, the syntax is (?:...) instead of the
traditional (...). This is very useful for when you define a group as merely a
set of meaningless sub-options that you don't want to actually match by
themselves.

I tried said format in D, but I got an exception saying: "*+? not allowed in
atom." Is there another way?

Thanks,
--AJG.
Jul 10 2005
parent "Walter" <newshound digitalmars.com> writes:
"AJG" <AJG_member pathlink.com> wrote in message
news:das10n$2hds$1 digitaldaemon.com...
 First off, why are D's regexes called RegExp? Most languages I've come

 use Regex. I know it's only one letter, but I make this mistake a lot.

I've seen both names used. I just picked one, for better or worse. The api isn't exactly the same as the regex commonly used in C libraries, so having a different name is a good idea.
 Second, is there support in the library for non-capturing groups and/or

 groups?

 Usually, for a non-capturing group, the syntax is (?:...) instead of the
 traditional (...). This is very useful for when you define a group as

 set of meaningless sub-options that you don't want to actually match by
 themselves.

 I tried said format in D, but I got an exception saying: "*+? not allowed

 atom." Is there another way?

The std.regexp regular expression syntax is as it existed before the innumerable Perl extensions to it. If you want to add some of them, feel free to take a whack at std.regexp <g>.
Jul 11 2005