Mercurial > hg > xemacs-beta
comparison man/lispref/searching.texi @ 442:abe6d1db359e r21-2-36
Import from CVS: tag r21-2-36
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:35:02 +0200 |
parents | 3ecd8885ac67 |
children | 576fb035e263 |
comparison
equal
deleted
inserted
replaced
441:72a7cfa4a488 | 442:abe6d1db359e |
---|---|
271 works just like @samp{*}, except that rather than matching the longest | 271 works just like @samp{*}, except that rather than matching the longest |
272 match, it matches the shortest match. @samp{*?} is known as a | 272 match, it matches the shortest match. @samp{*?} is known as a |
273 @dfn{non-greedy} quantifier, a regexp construct borrowed from Perl. | 273 @dfn{non-greedy} quantifier, a regexp construct borrowed from Perl. |
274 @c Did perl get this from somewhere? What's the real history of *? ? | 274 @c Did perl get this from somewhere? What's the real history of *? ? |
275 | 275 |
276 This construct very useful for when you want to match the text inside a | 276 This construct is very useful for when you want to match the text inside |
277 pair of delimiters. For instance, @samp{/\*.*?\*/} will match C | 277 a pair of delimiters. For instance, @samp{/\*.*?\*/} will match C |
278 comments in a string. This could not be achieved without the use of | 278 comments in a string. This could not easily be achieved without the use |
279 greedy quantifier. | 279 of a non-greedy quantifier. |
280 | 280 |
281 This construct has not been available prior to XEmacs 20.4. It is not | 281 This construct has not been available prior to XEmacs 20.4. It is not |
282 available in FSF Emacs. | 282 available in FSF Emacs. |
283 | 283 |
284 @item +? | 284 @item +? |
285 @cindex @samp{+?} in regexp | 285 @cindex @samp{+?} in regexp |
286 is the @samp{+} analog to @samp{*?}. | 286 is the non-greedy version of @samp{+}. |
287 | |
288 @item ?? | |
289 @cindex @samp{??} in regexp | |
290 is the non-greedy version of @samp{?}. | |
287 | 291 |
288 @item \@{n,m\@} | 292 @item \@{n,m\@} |
289 @c Note the spacing after the close brace is deliberate. | 293 @c Note the spacing after the close brace is deliberate. |
290 @cindex @samp{\@{n,m\@} }in regexp | 294 @cindex @samp{\@{n,m\@} }in regexp |
291 serves as an interval quantifier, analogous to @samp{*} or @samp{+}, but | 295 serves as an interval quantifier, analogous to @samp{*} or @samp{+}, but |
292 specifies that the expression must match at least @var{n} times, but no | 296 specifies that the expression must match at least @var{n} times, but no |
293 more than @var{m} times. This syntax is supported by most Unix regexp | 297 more than @var{m} times. This syntax is supported by most Unix regexp |
294 utilities, and has been introduced to XEmacs for the version 20.3. | 298 utilities, and has been introduced to XEmacs for the version 20.3. |
299 | |
300 Unfortunately, the non-greedy version of this quantifier does not exist | |
301 currently, although it does in Perl. | |
295 | 302 |
296 @item [ @dots{} ] | 303 @item [ @dots{} ] |
297 @cindex character set (in regexp) | 304 @cindex character set (in regexp) |
298 @cindex @samp{[} in regexp | 305 @cindex @samp{[} in regexp |
299 @cindex @samp{]} in regexp | 306 @cindex @samp{]} in regexp |
460 is called a @dfn{shy} grouping operator, and it is used just like | 467 is called a @dfn{shy} grouping operator, and it is used just like |
461 @samp{\( @dots{} \)}, except that it does not cause the matched | 468 @samp{\( @dots{} \)}, except that it does not cause the matched |
462 substring to be recorded for future reference. | 469 substring to be recorded for future reference. |
463 | 470 |
464 This is useful when you need a lot of grouping @samp{\( @dots{} \)} | 471 This is useful when you need a lot of grouping @samp{\( @dots{} \)} |
465 constructs, but only want to remember one or two. Then you can use | 472 constructs, but only want to remember one or two -- or if you have |
466 not want to remember them for later use with @code{match-string}. | 473 more than nine groupings and need to use backreferences to refer to |
474 the groupings at the end. | |
467 | 475 |
468 Using @samp{\(?: @dots{} \)} rather than @samp{\( @dots{} \)} when you | 476 Using @samp{\(?: @dots{} \)} rather than @samp{\( @dots{} \)} when you |
469 don't need the captured substrings ought to speed up your programs some, | 477 don't need the captured substrings ought to speed up your programs some, |
470 since it shortens the code path followed by the regular expression | 478 since it shortens the code path followed by the regular expression |
471 engine, as well as the amount of memory allocation and string copying it | 479 engine, as well as the amount of memory allocation and string copying it |
472 must do. The actual performance gain to be observed has not been | 480 must do. The actual performance gain to be observed has not been |
473 measured or quantified as of this writing. | 481 measured or quantified as of this writing. |
474 @c This is used to good advantage by the font-locking code, and by | 482 @c This is used to good advantage by the font-locking code, and by |
475 @c `regexp-opt.el'. ... It will be. It's not yet, but will be. | 483 @c `regexp-opt.el'. |
476 | 484 |
477 The shy grouping operator has been borrowed from Perl, and has not been | 485 The shy grouping operator has been borrowed from Perl, and has not been |
478 available prior to XEmacs 20.3, nor is it available in FSF Emacs. | 486 available prior to XEmacs 20.3, nor is it available in FSF Emacs. |
479 | 487 |
480 @item \w | 488 @item \w |