Somewhat off topic, but handy tidbit anyway (should be in dev-list *wink*)

You can use perl to do a search and replace like this:

perl -pi.bak -e 's/<regex>/<regex>/g' file(s)

Since ' and \ characters are 'recognized' in a regex, you have to escape
them in your stream:

perl -pi.bak -e 's/\'/\\\'/g' file(s)

or

perl -pi.bak -e 's/\\/\\\\/g' file(s)

The '-pi.bak' part will make backups of each of your files.

It might be easier just to do a search and replace with your favourite
editor.

This might not even be what you wanted... ;)


Charles Daminato
TUCOWS Product Manager (ccTLDs)
[EMAIL PROTECTED]

On Tue, 19 Dec 2000, Jim Carey wrote:

> Hi,
>
> can someone give me a head start on the simplest way to search through a
> string in Perl and escape any ' or \ characters found. I can do it in PHP
> but my attempts in Perl are worfule.
>
> cheers
>
> Jim Carey
>
>
>

Reply via email to