正则表达式:匹配特定单词的表达式
Regex : expression to match specific word
我有一个正则表达式替换功能:
reg_replace(Input_Column,'\b(?:(?!https|www|http)\w)+\b', 'x')
输入 www.google.com
,结果为 www.x.x
,而应为 www.xxxxxx.xxx
。
请帮我写一个按字母而不是按单词工作的正则表达式。
使用
\w(?!\w*\b(?<=\bhttps|\bwww|\bhttp))
说明
--------------------------------------------------------------------------------
\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
我有一个正则表达式替换功能:
reg_replace(Input_Column,'\b(?:(?!https|www|http)\w)+\b', 'x')
输入 www.google.com
,结果为 www.x.x
,而应为 www.xxxxxx.xxx
。
请帮我写一个按字母而不是按单词工作的正则表达式。
使用
\w(?!\w*\b(?<=\bhttps|\bwww|\bhttp))
说明
--------------------------------------------------------------------------------
\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