Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.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
Regex preg“u match”u all find string not“;http「;之后#_Regex_Preg Match All - Fatal编程技术网

Regex preg“u match”u all find string not“;http「;之后#

Regex preg“u match”u all find string not“;http「;之后#,regex,preg-match-all,Regex,Preg Match All,我需要找到一个字符串,该字符串不包含https或http,而是在# 演示: 我的代码是在#之后查找内容 preg_match_all(“/#([^\s]+)/”,$content,$matches) 这应该适合你 ^(http://)(?#) 我相信您首先要确保字符串是一个URL,然后再获取hashbang背后的所有内容?(包括hashbang)。那么我相信这个带有非捕获组的正则表达式会起作用: preg_match_all('/^(?:https*:\/\/.*)(#.*)$/', $url

我需要找到一个字符串,该字符串不包含
https
http
,而是在
#

演示:

我的代码是在#之后查找内容
preg_match_all(“/#([^\s]+)/”,$content,$matches)

这应该适合你

^(http://)(?#)

我相信您首先要确保字符串是一个URL,然后再获取hashbang背后的所有内容?(包括hashbang)。那么我相信这个带有非捕获组的正则表达式会起作用:

preg_match_all('/^(?:https*:\/\/.*)(#.*)$/', $url, $matches);
我怀疑您正在使用php:)


您可以在这里查看:

请更精确地描述您的实际输入和输出字符串。你的目标可以通过各种方式实现。
preg_match_all('/^(?:https*:\/\/.*)(#.*)$/', $url, $matches);
^(?!https?://).*?$