Skip to content

Instantly share code, notes, and snippets.

@carcam
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carcam/83456db4ec495dccafb9 to your computer and use it in GitHub Desktop.
Save carcam/83456db4ec495dccafb9 to your computer and use it in GitHub Desktop.
TESTING REGEXP for closing html tags
<?php
$mypattern = "([\w-.]+)+(:\d+)?(/([\w/_\-.]*(\?\S+)?)?)?(.*)?";
$pattern = '[a-zA-Z0-9&?_.,=%\-\/#]';
$url = "http://formaciononline.nccextremadura.org#formacion-desempleados";
$newurl = preg_replace('@(https?://'.$pattern.'*)@i', '<a href="$1">$1</a>', $url);
//echo "Old URL-> ".$url;
//echo "<br/>";
//echo "New URL -> ".htmlspecialchars($newurl);
$texto =
"<div> lorem ipsum<br/>
thing </ div ><p>más cosas > que cosas< / p ><table><tr><td></td >< /tr></TABLE>";
echo "<br/>";
echo htmlspecialchars(preg_replace("@(<\s*(br)*\s*\/\s*(p|td|tr|table|div)*\s*>)+?@i","$1JEVENTS",$texto));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment