comparison lispref/searching.texi @ 69413:774f0386ba3c

(Regexp Special): Use @samp for regular expressions that are not in Lisp syntax.
author Luc Teirlinck <teirllm@auburn.edu>
date Sat, 11 Mar 2006 21:23:11 +0000
parents 3b476a22dc6a
children 3e2a72a06085 a802c5505156
comparison
equal deleted inserted replaced
69412:ecc36e13e6ba 69413:774f0386ba3c
474 As a @samp{\} is not special inside a character alternative, it can 474 As a @samp{\} is not special inside a character alternative, it can
475 never remove the special meaning of @samp{-} or @samp{]}. So you 475 never remove the special meaning of @samp{-} or @samp{]}. So you
476 should not quote these characters when they have no special meaning 476 should not quote these characters when they have no special meaning
477 either. This would not clarify anything, since backslashes can 477 either. This would not clarify anything, since backslashes can
478 legitimately precede these characters where they @emph{have} special 478 legitimately precede these characters where they @emph{have} special
479 meaning, as in @code{[^\]} (@code{"[^\\]"} for Lisp string syntax), 479 meaning, as in @samp{[^\]} (@code{"[^\\]"} for Lisp string syntax),
480 which matches any single character except a backslash. 480 which matches any single character except a backslash.
481 481
482 In practice, most @samp{]} that occur in regular expressions close a 482 In practice, most @samp{]} that occur in regular expressions close a
483 character alternative and hence are special. However, occasionally a 483 character alternative and hence are special. However, occasionally a
484 regular expression may try to match a complex pattern of literal 484 regular expression may try to match a complex pattern of literal
485 @samp{[} and @samp{]}. In such situations, it sometimes may be 485 @samp{[} and @samp{]}. In such situations, it sometimes may be
486 necessary to carefully parse the regexp from the start to determine 486 necessary to carefully parse the regexp from the start to determine
487 which square brackets enclose a character alternative. For example, 487 which square brackets enclose a character alternative. For example,
488 @code{[^][]]} consists of the complemented character alternative 488 @samp{[^][]]} consists of the complemented character alternative
489 @code{[^][]} (which matches any single character that is not a square 489 @samp{[^][]} (which matches any single character that is not a square
490 bracket), followed by a literal @samp{]}. 490 bracket), followed by a literal @samp{]}.
491 491
492 The exact rules are that at the beginning of a regexp, @samp{[} is 492 The exact rules are that at the beginning of a regexp, @samp{[} is
493 special and @samp{]} not. This lasts until the first unquoted 493 special and @samp{]} not. This lasts until the first unquoted
494 @samp{[}, after which we are in a character alternative; @samp{[} is 494 @samp{[}, after which we are in a character alternative; @samp{[} is