[英]Regex : expression to match specific word
I have a regex replace function:我有一个正则表达式替换 function:
reg_replace(Input_Column,'\b(?:(?!https|www|http)\w)+\b', 'x')
With www.google.com
input, the result is www.xx
where as it should be www.xxxxxx.xxx
.使用www.google.com
输入,结果是www.xx
应该是www.xxxxxx.xxx
。
Please help me to write a regex which works by letters and not by words.请帮我写一个通过字母而不是单词工作的正则表达式。
Use利用
\w(?!\w*\b(?<=\bhttps|\bwww|\bhttp))
Explanation解释
--------------------------------------------------------------------------------
\w word characters (a-z, A-Z, 0-9, _)
--------------------------------------------------------------------------------
(?! look ahead to see if there is not:
--------------------------------------------------------------------------------
\w* word characters (a-z, A-Z, 0-9, _) (0 or
more times (matching the most amount
possible))
--------------------------------------------------------------------------------
\b the boundary between a word char (\w)
and something that is not a word char
--------------------------------------------------------------------------------
(?<= look behind to see if there is:
--------------------------------------------------------------------------------
\b the boundary between a word char (\w)
and something that is not a word char
--------------------------------------------------------------------------------
https 'https'
--------------------------------------------------------------------------------
| OR
--------------------------------------------------------------------------------
\b the boundary between a word char (\w)
and something that is not a word char
--------------------------------------------------------------------------------
www 'www'
--------------------------------------------------------------------------------
| OR
--------------------------------------------------------------------------------
\b the boundary between a word char (\w)
and something that is not a word char
--------------------------------------------------------------------------------
http 'http'
--------------------------------------------------------------------------------
) end of look-behind
--------------------------------------------------------------------------------
) end of look-ahead
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.