jareth(a)camelot.co.jp (P. E. Jareth Hein) writes:
I just got a 'bug-report' complaining that regexp-opt
generates
incorrect regexps. Well, asside from the fact that I'm not sure
regexp-opt should generate shy groups by default, I do notice that
there is no mention of the shy groups functions or the minimal
matching operators in the info files.
Huh? My info files contain this:
`*?'
works just like `*', except that rather than matching the longest
match, it matches the shortest match. `*?' is known as a
"non-greedy" quantifier, a regexp construct borrowed from Perl.
This construct very useful for when you want to match the text
inside a pair of delimiters. For instance, `/\*.*?\*/' will match
C comments in a string. This could not be achieved without the
use of greedy quantifier.
This construct has not been available prior to XEmacs 20.4. It is
not available in FSF Emacs.
`+?'
is the `+' analog to `*?'.
`\{n,m\}'
serves as an interval quantifier, analogous to `*' or `+', but
specifies that the expression must match at least N times, but no
more than M times. This syntax is supported by most Unix regexp
utilities, and has been introduced to XEmacs for the version 20.3.
`\(?: ... \)'
is called a "shy" grouping operator, and it is used just like `\(
... \)', except that it does not cause the matched substring to be
recorded for future reference.
This is useful when you need a lot of grouping `\( ... \)'
constructs, but only want to remember one or two. Then you can use
not want to remember them for later use with `match-string'.
Using `\(?: ... \)' rather than `\( ... \)' when you don't need
the captured substrings ought to speed up your programs some,
since it shortens the code path followed by the regular expression
engine, as well as the amount of memory allocation and string
copying it must do. The actual performance gain to be observed
has not been measured or quantified as of this writing.
The shy grouping operator has been borrowed from Perl, and has not
been available prior to XEmacs 20.3, nor is it available in FSF
Emacs.
--
Hrvoje Niksic <hniksic(a)srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
What is mind? No matter.
What is matter? Never mind.