找到&格式缩写,如果可能,用N ++格式

时间:2015-06-21 21:28:44

标签: regex notepad++

我想在文本中找到三个或更多连续大写字母的所有实例,并在它们之间放置句点。例如:

POTUS - > P.O.T.U.S

DL - > DL [未更改}

先生。 - >先生[未更改]

FGB4D - > F.G.B4D

可以在Notepad ++ RegEx中完成吗?或者我需要PHP,Python等吗?

1 个答案:

答案 0 :(得分:1)

使用记事本++:

search: (?:\G(?!\A)|\b(?=[A-Z]{3,}))[A-Z](?=[A-Z])\K

replace: .

模式细节:

(?: # two possible starts:
    \G(?!\A) # contiguous to the previous match (not at the start of the string)
  |          # OR
    \b       # a word boundary (if you don't need you can remove it)
    (?=[A-Z]{3,}) # followed by at least three letters 
)
[A-Z] # a letter
(?=[A-Z]) # followed by an other letter
\K # discards all characters on the left from match result