Re: Regexp: \m and [^[:alnum:]_] are not equivalent
- From: Donald Arseneau <asnd@xxxxxxxxx>
- Date: 06 Sep 2005 15:50:32 -0700
"Francois Vogel" <fsvogelnew5NOSPAM@xxxxxxx> writes:
> In regexps, the \m escape is advertised to match at the beginning of a word.
Yes.
> What is defined as a word in the re_syntax man page is an alnum or an
> underscore, i.e. [[:alnum:]_]
Yes.
> From that I deduce I can match at the beginning of a word if I use the
> negative of the above, i.e. [^[:alnum:]_]
No! That is how you match anything that is not a word!
\m is the zero-length match of the boundary between non-word and
word. If you want to simulate it by other means, see the lookahead
(?=[[:alnum:]_]). There's no look-behind syntax though, so I don't
know how to exactly duplicate the behaviour of \m.
--
Donald Arseneau asnd@xxxxxxxxx
.
- References:
- Regexp: \m and [^[:alnum:]_] are not equivalent
- From: Francois Vogel
- Regexp: \m and [^[:alnum:]_] are not equivalent
- Prev by Date: Re: Wikipedia
- Next by Date: Re: installing BLT 2.4z
- Previous by thread: Re: Regexp: \m and [^[:alnum:]_] are not equivalent
- Next by thread: tcl plugin for MacOSX Spotlight?
- Index(es):
Relevant Pages
|