$x = preg_replace( "/([^\s&])&([^\s&])/", "$1&&$2", $x );
should do the job.
Michael

Neil Freeman <[EMAIL PROTECTED]> schrieb:

> 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: [EMAIL PROTECTED]
> Home: [EMAIL PROTECTED]
>
> Web:  www.curvedvision.com
> ----------------------------
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to