PHP Regex Repository
A collection of regular expression: canonical (tested with common practical applications), special cases, and developmentalCanonical
Special Cases
Developmental
// pipes should be padded with 1 (and only 1!) space on each side
if ( 1 )
{
$str = 'xx|xx | av | a asd| asd |xxx | abc';
echo "<pre>$str</pre>";
$r = str_replace('|', ' | ', $str);
$r = preg_replace('%\s+%', ' ', $r);
$r = str_replace(' ','%',$r);
echo "<pre>$r</pre>";
}
if ( 1 )
{
$str = 'xx|xx | av | a asd| asd |xxx | abc';
echo "<pre>$str</pre>";
$r = str_replace('|', ' | ', $str);
$r = preg_replace('%\s+%', ' ', $r);
$r = str_replace(' ','%',$r);
echo "<pre>$r</pre>";
}
Sandbox
CategoryPhp
[Add comment]