Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.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 需要正则表达式在特殊字符之前添加字符串_Regex - Fatal编程技术网

Regex 需要正则表达式在特殊字符之前添加字符串

Regex 需要正则表达式在特殊字符之前添加字符串,regex,Regex,我有一条推特,我需要匹配#regex并添加 <a href=twitter.com/#!/search/%23regex>#regex</a> 我使用下面的方法将锚添加到https "(?:https?|ftps?)://[\\w/%.-]+", "<a href='$0'>$0</a>" “(?:https?| ftps?)://[\\w/%.-]+” 可能对其进行了一些修改,可能会起作用?不清楚您使用的是哪种语言,但我会尝试以下方法

我有一条推特,我需要匹配#regex并添加

 <a href=twitter.com/#!/search/%23regex>#regex</a>

我使用下面的方法将锚添加到https

"(?:https?|ftps?)://[\\w/%.-]+", "<a href='$0'>$0</a>"
“(?:https?| ftps?)://[\\w/%.-]+”

可能对其进行了一些修改,可能会起作用?

不清楚您使用的是哪种语言,但我会尝试以下方法:

"#\\w+", "<a href='twitter.com/#!/search/%23$0'>$0</a>"
“#\\w+”

这应该捕获任何后跟一系列字母数字字符的
序列。

#regex是我需要查找的一个示例,然后对下一个单词执行操作。如何删除第二个$0中的#?对
使用正向查找,以便它用于匹配,但不被捕获:
(?