Find a regular expression that matches URL parameters, such as www.sina.com. cnsports? P3456www.sina.com. cnsports? Why 923www.sina.com. cnsportsbasktball? P878923 need to match now? The parameter in p is the added black part. I used the method to find a regular expression that matches the URL parameter.
For example
Http://www.sina.com.cn/sports? P =
3456
Http://www.sina.com.cn/sports? P =
38923
Http://www.sina.com.cn/sports/basktball? P =
878923
Need to match now? P = the parameter in it is the black part.
The method I use is,
^ /? ([A-z/] + )/\? P = ([0-9] +)
Can match the previous parameter, but there is no way to match "? = P "is followed by a number parameter. how can I write this regular expression? Thank you!
------ Solution --------------------
Preg_match ('/p = (\ d +)/', $ s, $ m );
Echo $ m [1];
------ Solution --------------------
2 loou good
------ Solution --------------------
Preg_match ('/(? <= \? P =) \ d +/', $ str, $ match );
Echo $ match [0];
------ Solution --------------------
(? <= P \ =) \ d +