[英]Regex replace between notepad++
我在 csv 中有一個值列表,我試圖使用 REGEX 搜索稍微改變它並使用 Notepad++ 替換。 我所擁有的包含以下示例:
Text,UK_BT.BT1.BT1 1,123
Text,UK_BT.BT11.BT11 1,123
Text,IE_text.text.text,123
我想要做的是刪除第一個逗號和最后一個句點之間的文本,僅在該行包含 UK_BT 的地方。 所以輸出將是:
Text,BT1 1,123
Text,BT11 1,123
Text,IE_text.text.text,123
有沒有人有任何線索? 正則表達式真的不是我的強項,使用后通常會被遺忘! 謝謝,
找到什么: ^(?=.*UK_BT.*)([^,]+,).*\\.([^\\.]+)$
替換為\\1\\2
說明
^ # Beginning of the line.
(?=.*UK_BT.*) # Must contain 'UK_BT' (positive look ahead, not capturing group, not character consuming).
( # Beginning of the first group.
[^,]+, # Everything but ',' at least one time (+) followed by ',' (first ',').
) # End of the first group.
.* # Everything zero or more times.
\. # A single '.'.
( # Beginning of the second group.
[^\.]+ # Everything but '.' at least one time (this in combination with '\.' allows to find the last '.').
) # End of the second group.
$ # End of the line
\\1\\2
允許指向第一個和第二個捕獲的組。
下次試試吧,下次不會忘記的。。。
查找內容: UK.+\\d\\.
替換為: nothing
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.