Last active
August 29, 2015 14:17
-
-
Save carcam/83456db4ec495dccafb9 to your computer and use it in GitHub Desktop.
TESTING REGEXP for closing html tags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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