regex - Splitting expression by regular expressions (PHP) -
i want split string: "33a/5" on parts "33", "a", "5".
is in php possibility write regex as: "/^(\d+) (\d) \/? (\d+)/"
, expressions in brackets ( exp )
become separate parts?
you can use preg_match
this:
preg_match("/^(\d+) (\d+) \/? (\d+)/x", $text, $match);
$match
array separate matches.
the x
modifier ignore spaces in regex; otherwise, don't put spaces:
preg_match("/^(\d+)(\d+)\/?(\d+)/", $text, $match);
Comments
Post a Comment