Advanced Regexps?

Kent Boortz kent@REDACTED
Wed Dec 3 04:56:23 CET 2003

Bengt Kleberg <Bengt.Kleberg@REDACTED> writes:
> since i do not know perl i would like to ask if you mean that perl has
> a special regexp for matching word boundaries? (ie, not
> [\s]+[a-zA-Z]+[\s]+ , but something else).

>From "man perlre"

     Perl defines the following zero-width assertions:

         \b  Match a word boundary
         \B  Match a non-(word boundary)
         \A  Match only at beginning of string
         \Z  Match only at end of string, or before newline at the end
         \z  Match only at end of string
         \G  Match only at pos() (e.g. at the end-of-match position
             of prior m//g)

     A word boundary ("\b") is a spot between two characters that
     has a "\w" on one side of it and a "\W" on the other side of
     it (in either order), counting the imaginary characters off
     the beginning and end of the string as matching a "\W".

It has other additions as well, like the modifiers

     m   Treat string as multiple lines.  That is, change "^" and
         "$" from matching the start or end of the string to
         matching the start or end of any line anywhere within
         the string.

     s   Treat string as single line.  That is, change "." to
         match any character whatsoever, even a newline, which
         normally it would not match.

It is also possible to specify if '*' and '+' are to be eager or
not. Perl has lots of more extensions that makes the expressions short
and powerful,


More information about the erlang-questions mailing list