Regex ignore html entities but replace any '&' with &


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. preg_replace("/&(?![a-zA-Z0-9#]+;{1})/", "&", $str);
  2.  
  3.  
  4. Test here: http://regexpal.com/
  5. Regex: &(?![a-zA-Z0-9#]+;{1})
  6. Test case: &  j&j hh jk 8 $ & nnj & dasasd E&P d d&d 11

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.