SPUG: regular expressions

Yitzchak Scott-Thoennes sthoenna at efn.org
Tue Jan 17 14:14:24 PST 2006


On Tue, Jan 17, 2006 at 02:07:14PM -0800, Randy Rue wrote:
> Bear with me for a newbie question, I'm right at the second regex 
> chapeter in Learning Pearl and this question caught my attention:
> 
> What does the (\w) in the pattern do to the \b word separator? I thought 
> it might give whitespace as the word delimiter (and so keep words like 
> "that's" as a single word) but the output still comes out as "That'S."
> 
> How else could I treat contractions?

Whitespace as word delimiter doesn't work if you have 'quoted text'.

Contractions are messy, something like:

s/\b(?<!\w')(\w+)/\u$1/g


More information about the spug-list mailing list