[CS-FSLUG] regexp help

Robert W. robertwo at access-4-free.com
Thu Nov 11 20:32:36 CST 2004


On 11/11/2004 07:36:38 PM, Tim Young wrote:
> Yup.  I guess it does work.  Just goes to show there is a zillion  
> ways
> to do it
> with Linux tools.  Anyone want to try to find a command-line with  
> less
> characters
> than Frank's?
> 
>     - Tim Young

I can't resist...
perl -pi -e 's/(\w)-(\w)/$1--$2/'

My test file looks like...
abc-def
-ghi
jkl-
xyz
lmno--pqr

After the above command, it looks like...
abc--def
-ghi
jkl-
xyz
lmno--pqr

One note, the "\w" matches alphanumeric and an underscore.

--
Robert W.
robertwo at access-4-free.com

And the LORD said... "I will have mercy on whom I have mercy, and I
will have compassion on whom I will have compassion." -- Exodus 33:19b




More information about the Christiansource mailing list