This is my archive of regular expressions for use in php usually with the preg_match type functions. If you can improve on these I’d like to know as they are mostly just harvested from other sources as I need them and it’s possible they could be improved:
This code isn’t strictly correct as word press’s inbuilt editor modifies it – I’m trialing code highlighters at the moment to avoid this email me in the mean time for the correct version if you need it.
Match url in parts:
This is split into parts to make the components of the expression obvious for maintenance
-
-
$match_host = "([a-zd][-a-zd]*[a-zd].)*[a-z][-a-zd]*[a-z]";
-
$match_port = "(:d{1,})?";
-
$match_path = "(/[^?<>#"s]+)?";
-
$match_query = "(?[^<>#"s]+)?";
-
$match_url = "/(?:(?<=^)|(?<=s))((ht|f)tps?://" . $match_host . $match_port . $match_path . $match_query .")/";
-
Convert Multiple Spaces To a Single Space:
This is actually the way to convert any multiple elements to a single element
0 Responses to “Regular Expression Archive”
Please Wait
Leave a Reply
You must login to post a comment.