RegExp - Replacing 'R&B' with 'R&&B'
| From: | Neil Freeman | Date: | Tue, 11 Jun 2002 09:15:02 +0000 |
| Subject: | RegExp - Replacing 'R&B' with 'R&&B' | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-101510@lists.php.net to get a copy of this message | ||
Hi,
For all you Unix gurus this should be run of the mill stuff but us Windows boys tend to get confused easily :)
How can I easily match occurrences of text along the lines of R&B and replace it with R&&B ?
The regular expression s/&/&&/g obviously replaces any occurrence of an ampersand with a double ampersand but I need to do a match so that it only replaces instances which have non whitespace on either side of it, ie \S&\S
I think I'm along the right lines but haven't had enough experience with regular expressions yet to 'finish the job'.
Hope you can help.
Neil
--
----------------------------
Work: neil.freeman@asa.co.uk
Home: neil@curvedvision.com
Web: www.curvedvision.com
----------------------------