[olug] Regex question

Christopher Cashell topher-olug at zyp.org
Tue Oct 10 03:05:49 UTC 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

At Mon, 09 Oct 06, Unidentified Flying Banana Christopher Cashell, said:
> At Mon, 09 Oct 06, Unidentified Flying Banana Adam Haeder, said:
> > But the same regex _does not_ work when passed to sed.
> > 
> > What am I doing wrong?
> 
> Try:
> 
>   sed 's/\d226/-/'

Grrr.  Apologies for replying to myself, but I forgot to take into
account the two numbers following the special character that you
mentioned.  A more complete choice than above would be:

  sed 's/\d226[0-9][0-9]/-/'

or

  sed -r 's/\d226[0-9]{2}/-/'

> This tells sed to replace the ASCII character represented by dDDD
> (decimal DDD) with a dash.  Alternately, you can use xXX (hex) or oOOO
> (octal), as well.
> 
> Should work for GNU sed, at least.
> 
> > --
> > Adam Haeder

- -- 
| Christopher
+------------------------------------------------+
| Here I stand.  I can do no other.              |
+------------------------------------------------+

-----BEGIN PGP SIGNATURE-----

iD8DBQFFKw4NEhJxA932ZEYRAklnAKCq1dEtoSwDs0iNJSBVbufcvcbopwCgvuX2
XeEoeNXOxthvmCy4NUENDf0=
=pxLb
-----END PGP SIGNATURE-----



More information about the OLUG mailing list