Sorry for the newbie question…It seems the parenthesis provide two different functions in a regex. One is for grouping but the other is for extracting strings (eg. a(.*)z to extract the string between the ‘a’ and ‘z’ characters). How would you do a grouping inside of an expression where you want to do an extraction? Wouldn’t the regex interpreter just interpret both sets of parenthesis as extractions? How would you include a grouping operation within a regex where you are doing an extraction? Hopefully that makes sense.
Sorry for the newbie question…It seems the parenthesis provide two different functions in a
Share
Depends on the regex flavor (language), but in most flavors that matter(*),
(?:starts a “non-capturing group”, and)ends it as usual. I.e.Will match “abc” or “cba” followed by 1 or more arbitrary characters, and only those arbitrary characters will be captured (“extracted”).
*) When I say “most that matter”, that means anything except POSIX and GNU. I.e. .NET, Javascript, Java, Python, Ruby, Perl, PHP etc. The one important flavor where it’s not supported is XPath (and XML Schema).