help-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How Is \B Supposed to Work in Regexps?


From: Neil R. Ormos
Subject: Re: How Is \B Supposed to Work in Regexps?
Date: Wed, 7 Sep 2022 14:05:44 -0500 (CDT)

Wolfgang Laun wrote:
> Neil R. Ormos wrote:

>> The \B regexp operator doesn't appear to work
>> as described in the manual.

>> In manual Section "3.7 gawk-Specific Regexp
>> Operators", \B is said to match

>> | the empty string that occurs between two
>> | word-constituent characters. For example,
>> | /\Brat\B/ matches 'crate', but it does not match
>> | 'dirty rat'. '\B' is essentially the opposite of
>> | '\y'.

>> \B seems to match even strings that contain no
>> word-constituent characters. [...]

> \B matches when not at a word boundary

> It might become clearer when you run the slightly modified matching
> operation:

> echo "///"    | awk '{h = $0; p = gsub( /\B/, "!" ); print p " >" h "< >"
> $0 "<";}'
> 4 >///< >!/!/!/!<

> [...]

Thank you, Wolfgang, for that explanation.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]