Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/256.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 正则表达式(preg_match)-id和随机字符_Php_Regex_Preg Match_Preg Match All - Fatal编程技术网

Php 正则表达式(preg_match)-id和随机字符

Php 正则表达式(preg_match)-id和随机字符,php,regex,preg-match,preg-match-all,Php,Regex,Preg Match,Preg Match All,我想找到像下面的preg_匹配的URL http://www.website.com/THE_ID_WHICH_I_WANT/RANDOM_CHARACTERS_AND_NUMBERS.RANDOM_SOMETHING.html 这就是我取得的成绩: preg_match_all('%http://www.website\.com\/(\w+)%', $string, $matches); 但我也希望它能得到随机字符 谢谢。preg\u match\u all('%http://www\

我想找到像下面的preg_匹配的URL

 http://www.website.com/THE_ID_WHICH_I_WANT/RANDOM_CHARACTERS_AND_NUMBERS.RANDOM_SOMETHING.html 
这就是我取得的成绩:

preg_match_all('%http://www.website\.com\/(\w+)%', $string, $matches);
但我也希望它能得到随机字符

谢谢。

preg\u match\u all('%http://www\.website\.com/(\w+/(.*)\.html%',$string,$matches)

以上假设您希望将“我想要的”这个\u ID\u与其他随机字符分开

示例:

要匹配任何内容,通常使用
+
或非贪婪的
*?


您可能希望使用
\S+
来匹配任何非空格字符。即使这样,也可能太多了。但是您没有详细说明要在其中使用它的上下文。

谢谢。这正是我想要的答案。