[plug] Scripting Help - Search, Mangle, Replace

Timothy White weirdit at gmail.com
Sat Jun 23 09:19:22 WST 2007


Thanks, that helped me heaps!


> This does the trick, but sorry - uses perl :)
>
> perl -n -e 's/<U>([^<]+)<\/U>/"<sup>" . `echo -n $1` . "<\/sup>"/eg; print;'
>
I've tried modifying the same command, to do some other work,
specifically conditional removing of new lines (i.e. remove a new
line, except when the last char in the line is a >).
It was a little later than I discovered that if I have the 'e'
modifier, then the space in my replace patter is ignored.

 perl -n -e 's/(?<!\>)\n/ /eg; print'

a
b
c
becomes
abc

Removing the 'e' modifier means the space is added in as per the pattern.

 perl -n -e 's/(?<!\>)\n/ /g; print'

a
b
c
becomes
a b c

Can someone explain why, as I can't seem to find much on the 'e'
modifier. (At least nothing more than a short bit in the perl docs
about adding it if you are a often making a certain mistake.)

Should I use it, or not? If I try having a \n for example in the
replace pattern, with the 'e' modifier it throws up an error.

Thanks

Tim
-- 
Linux Counter user #273956
Don't email joeblogs at scouts.org.au



More information about the plug mailing list