How do I match a regular expression like link344565? the numbers are random and the last number may not be linked? ([0-9] {1 ,})? ([0-9] {1 ,})? $ Why is it wrong to write this? I don't know much about it. ask experts for help with regular expression matching.
How to match the link/3445/65 format? the numbers are random and the last number may not exist.
Link /? ([0-9] {1 ,})/? ([0-9] {1 ,})/? $ Why is it wrong to write this? I don't know much about it. ask for help.
Share:
------ Solution --------------------
$ Subject = "link/3445/65 ";
$ Pattern = '# link /? ([0-9] *)/? ([0-9] *)/? $ #';
Preg_match ($ pattern, $ subject, $ matches );
Print_r ($ matches );
?>
------ Solution --------------------
$ S = "link/3445/644445 ";
$ Reg = '/link \/([\ d] *) \/([\ d] *) $/I ';
Preg_match ($ reg, $ s, $ );
Print_r ($ );
------ Solution --------------------
First, if you do not need to obtain the specific content in the matching, do not add parentheses everywhere. parentheses are used to obtain the content in the matching.
$ Reg = '/link \/\ d + \/\ d * $/I ';