Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## What I've suggested:
- # Please bear in mind, I'm not a PHP user, but I've run this against a PHP Regular Expression tester and it seems to work.
- $pee = "<span style="color:red;">Woo Woo</span>";
- $pee = preg_replace('/<span((?:!>|.)*)>(.*)<\/span>/', "<strong$1>$2</strong>", $pee);
- # output:
- # string(43) "<strong style="color:red;">Woo Woo</strong>"
- # Let me know if it works as expected.
- ## What you wanted:
- # this function takes the attributes from a span and plonks them into a strong - this is my basis, all cool.
- $pee = preg_replace('/<span([^>]*)>/', "<strong$1>", $pee);
- # what I have is a urlencoded string, and want to unencode the spans, using something like this (just swapping > for > and < for < on the spans)
- $pee = preg_replace('/<span([^>]*)>/', "<span$1>", $pee);
- # but this doesn't work, because the [^>] is searching for any character in there, and not the whole phrase
- # WHAT I WANT
- # input:
- <span style="color:red;">Woo Woo<span>
- #output:
- <span style="color:red;">Woo Woo</span>
- # i would otherwise run php's url decode, but i only want it to decode spans
Add Comment
Please, Sign In to add comment