February 11th, 2010, 12:54 PM
[Q] simple preg replace pattern
In the following example if $link was contain '?', I lose my pattern
any ideas ?
$string = preg_replace('!<a[^>](.*)(href="'. $link .'")(.*)</a>!siU', $linkReplace, $string);
2- what if i want to know more about these pattern ?
February 11th, 2010, 01:01 PM
2. google regular expressions
February 11th, 2010, 01:31 PM
Thanks a lot,
what if i don't want <a> tags which has a rel='nofollow' ?
how can I put this exception ?
February 11th, 2010, 11:18 PM
I can see that by adding ' ! '
But i get errors
February 12th, 2010, 08:30 AM
You're using " ! " as your delimiter, attempting to use it in the pattern is going to throw errors. ! has no special significance in regular expressions anyway.
In order to find strings not containing other strings, you'd need to make use of lookaheads in your regular expression. At this point, a well-written tutorial or book will have a better chance of helping you than we will.
Thread moved to regex.
HEY! YOU! Read the New User Guide and Forum Rules
"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin
"The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002
Think we're being rude? Maybe you asked a bad question
or you're a Help Vampire.
Trying to argue intelligently? Please read this.