Mailinglist Archive: opensuse (2532 mails)

< Previous Next >
Re: [opensuse] regexp -- defference between \< and \b ? (fwd)

----- Original Message ----- From: "Jan Engelhardt" <jengelh@xxxxxxxxxxxxxxx>
To: <opensuse@xxxxxxxxxxxx>
Sent: Thursday, May 01, 2008 2:59 AM
Subject: Re: [opensuse] regexp -- defference between \< and \b ? (fwd)

On Wednesday 2008-04-30 15:53, Randall R Schulz wrote:
>> With regular expressions, what is the difference between \< and
>> \b ? The man page says:
> Which man page? ...

Actually it comes from man grep. Specifically:

The Backslash Character and Special Expressions
The symbols \< and \> respectively match the empty string at
the beginning and end of a word. The symbol \b matches the empty
string at the edge of a word, ...

I guess it's been a long time since I've read the man page for the grep
family. I didn't realize \b and \B were a part of Gnu grep.

PCRE does not seem to know \<, so \b is what you would want these days.

\< and \> seem archaic, there does not seem to be a \<-based pattern
that could not be expressed with \b.

Isn't that like saying any line boundary is the same as begining of line?

To me \< and \> are exactly as useful as ^ and $

Or is the argument that you get the same thing as , \< or \> naturally by where you place any further expression context in relation to \b? ie: \bstuff or \b.* automatically = \< and stuff\b or .*\b automatically = \> ? does that actually work out? Say if you wanted to match simply the begining of every word, or the beginning of the nth word after/before some other expression, etc.. but you don't know or care what the word itself is.

Brian K. White brian@xxxxxxxxx
filePro BBx Linux SCO FreeBSD #callahans Satriani Filk!

To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx

< Previous Next >