RegEx with notepad++:删除两组文本
RegEx with notepad++: Remove two groups of text
我把这个字符串放在一行上:
('some text', 'some text', 'some text', '{\n {\n {\n . <p>Some text<br>Some text<br>Some text<br></p> \n} \n} \n}', 'some text' , 'some text')
我希望使用 RegEx 和记事本++得到这个结果:
('some text', 'some text', 'some text', '<p>Some text<br>Some text<br>Some text<br></p>', 'some text' , 'some text')
可能吗?有人可以帮助我吗?
谢谢
是的,您可以简单地在要删除的两组之间使用 OR(|) 运算符,并用反斜杠取消反斜杠
({\n {\n {\n .)|( \n} \n} \n})
在替换选项卡中,select正则表达式搜索模式
- Ctrl+H
- 查找内容:
{.+?(?=<)|(?<=>)[^<>]+}
- 替换为:
LEAVE EMPTY
- 检查 匹配大小写
- 检查 环绕
- 检查 正则表达式
- 取消选中
. matches newline
- 全部替换
解释:
{ # opening brace
.+? # 1 or more any character but newline
(?=<) # positive lookahead, make sure we have < after
| # OR
(?<=>) # positive lookbehind, make sure we have > before
[^<>]+ # 1 or more any character that is not < or >
} # closing brace
屏幕截图(之前):
截图(后):
我把这个字符串放在一行上:
('some text', 'some text', 'some text', '{\n {\n {\n . <p>Some text<br>Some text<br>Some text<br></p> \n} \n} \n}', 'some text' , 'some text')
我希望使用 RegEx 和记事本++得到这个结果:
('some text', 'some text', 'some text', '<p>Some text<br>Some text<br>Some text<br></p>', 'some text' , 'some text')
可能吗?有人可以帮助我吗? 谢谢
是的,您可以简单地在要删除的两组之间使用 OR(|) 运算符,并用反斜杠取消反斜杠
({\n {\n {\n .)|( \n} \n} \n})
在替换选项卡中,select正则表达式搜索模式
- Ctrl+H
- 查找内容:
{.+?(?=<)|(?<=>)[^<>]+}
- 替换为:
LEAVE EMPTY
- 检查 匹配大小写
- 检查 环绕
- 检查 正则表达式
- 取消选中
. matches newline
- 全部替换
解释:
{ # opening brace
.+? # 1 or more any character but newline
(?=<) # positive lookahead, make sure we have < after
| # OR
(?<=>) # positive lookbehind, make sure we have > before
[^<>]+ # 1 or more any character that is not < or >
} # closing brace
屏幕截图(之前):
截图(后):