[SLUG] Quick question

Al Girling al at gcguk.demon.co.uk
Tue Jul 15 09:54:52 BST 2008


On Tue, Jul 15, 2008 at 07:18:53AM BST, Stephen O'Neill wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Al Girling wrote:
> > Of course, you could use this to your advantage by writing your regex
> > as:
> > 
> > sed -i 's/KoolTrax/&\™/g' *.php*
> > 
> > because the Ampersand captures the search expression and reuses it as
> > part of the replacement.

I dug out my regex reference book last night and checked this.  It seems
that the previous comment is only correct for sed and vi/vim regex
engines.

> Ahhh... *scribbles furiously*.
> 
> 
> > Something else to note is your search expression isn't restricted to
> > KoolTrax.  It seems unlikely in this instance, but if your search was
> > for say, quick.  As the expression is currently, it would match quickly,
> > quickest etc.  So you would need to use:
> > 
> > sed -i 's/\<KoolTrax\>/&\&#153;/g' *.php*
> 
> In that instance I would tend to use the word boundary character class -
> is '\<word\>' exactly equivalent to '\bword\b'?

Certainly in sed.  The \bword\b regex doesn't work in vi/vim though.

This is heading into the realms of 'I love computing standards because
there are so many to choose from' though. :)

Toodle pip,

Al

-- 
Al Girling

Linux User: #290080             <http://counter.li.org>
Home-page:                      <http://al.sdf-eu.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.lug.org.uk/pipermail/scarborough/attachments/20080715/7fa3d566/attachment.bin


More information about the Scarborough mailing list