[Chicago-talk] Regular expression question

Andrew Rodland arodland at comcast.net
Fri May 1 19:29:05 PDT 2009

On Friday 01 May 2009 08:56:21 pm Jay Strauss wrote:
> On Fri, May 1, 2009 at 6:17 PM, Joshua McAdams <joshua.mcadams at gmail.com> 
> > Could you get by with s/\bEft\b/EFT/
> Would you please explain to the slow ones in the class (me) why/how
> the solution is not not equal to the problem?

\b matches the boundary between a \w word char and a \W nonword char (or 
start/end of string). So that pattern would match if "Eft" is bounded by any 
non-word chars, for instance "Newt-Eft-Salamander" will become "Newt-EFT-
Salamander" under that substitution because "-" is a nonword char, so \b will 
match between "-" and "E" and between "t" and "-".


More information about the Chicago-talk mailing list