Guest User

Untitled

a guest
May 23rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. ## What I've suggested:
  2. # 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.
  3.  
  4. $pee = "<span style="color:red;">Woo Woo</span>";
  5. $pee = preg_replace('/<span((?:!>|.)*)>(.*)<\/span>/', "<strong$1>$2</strong>", $pee);
  6.  
  7. # output:
  8. # string(43) "<strong style="color:red;">Woo Woo</strong>"
  9.  
  10. # Let me know if it works as expected.
  11.  
  12. ## What you wanted:
  13. # this function takes the attributes from a span and plonks them into a strong - this is my basis, all cool.
  14. $pee = preg_replace('/<span([^>]*)>/', "<strong$1>", $pee);
  15.  
  16. # 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)
  17.  
  18. $pee = preg_replace('/<span([^>]*)>/', "<span$1>", $pee);
  19.  
  20. # but this doesn't work, because the [^>] is searching for any character in there, and not the whole phrase
  21.  
  22. # WHAT I WANT
  23.  
  24. # input:
  25.  
  26. <span style="color:red;">Woo Woo<span>
  27.  
  28. #output:
  29.  
  30. <span style="color:red;">Woo Woo</span>
  31.  
  32. # i would otherwise run php's url decode, but i only want it to decode spans
Add Comment
Please, Sign In to add comment