我在csv中有一个值列表,我试图使用REGEX搜索略微改变并使用Notepad ++替换。我所拥有的内容包含以下示例:
SubmitUpdates
我想要做的是删除第一个逗号和上一个句点之间的文字, only ,其中该行包含UK_BT。所以输出将是:
Text,UK_BT.BT1.BT1 1,123
Text,UK_BT.BT11.BT11 1,123
Text,IE_text.text.text,123
有没有人有任何线索?正则表达式真的不是我的强点,使用后通常会被遗忘! 谢谢,
答案 0 :(得分:3)
找到:^(?=.*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
允许指向第一个和第二个捕获组。
答案 1 :(得分:0)
下次你不会忘记的时候试试...
查找内容:UK.+\d\.
替换为:nothing