grifdail

make regex

Apr 13th, 2012
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.21 KB | None | 0 0
  1. function makeRegex($text)
  2. {
  3.     $text=preg_replace('#{([a-z]+)-d}#',"(?P<\${1}>[0-9]+)",$text);
  4.     $text=preg_replace('#{([a-z]+)-t}#',"(?P<\${1}>[a-zA-Z0-9]+)",$text);
  5.     $regex="~".$text.'~';
  6.     return $regex;
  7. }
Advertisement
Add Comment
Please, Sign In to add comment