Basic RegEx question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • m|sf|t

    Basic RegEx question

    All,
    If I have this:

    $xmlstr = str_replace("&" , "%amp;%", $xmlstr);

    How can I use use a regex expression (if it is needed) to do the replace
    UNLESS the string contains A&E (you know, the TV channel).
    Thanks.


  • DH

    #2
    Re: Basic RegEx question

    m|sf|t wrote:[color=blue]
    > All,
    > If I have this:
    >
    > $xmlstr = str_replace("&" , "%amp;%", $xmlstr);
    >
    > How can I use use a regex expression (if it is needed) to do the replace
    > UNLESS the string contains A&E (you know, the TV channel).
    > Thanks.
    >
    >[/color]

    $xmlstr =
    stristr($xmlstr , 'A&E')
    ? 'A&E'
    : str_replace("&" , "%amp;%", $xmlstr);

    Comment

    Working...