简体   繁体   English

带有记事本++的正则表达式:删除两组文本

[英]RegEx with notepad++: Remove two groups of text

i have this string on a line:我在一行上有这个字符串:

('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')

and i would to have this result using RegEx with notepad++:我想使用带有记事本++的正则表达式得到这个结果:

('some text', 'some text', 'some text', '<p>Some text<br>Some text<br>Some text<br></p>', 'some text' , 'some text')

Is it possible?是否可以? Someone can help me?有人可以帮助我吗? Thank you谢谢

Yes, you can simply use the OR(|) operator between the two groups you want to remove, and cancel out the backslashes with a backslash是的,您可以简单地在要删除的两个组之间使用 OR(|) 运算符,并用反斜杠取消反斜杠

({\\n  {\\n  {\\n .)|( \\n} \\n} \\n})

in the replace tab, and select the regular expressions search mode在替换选项卡中,选择正则表达式搜索模式

  • Ctrl + H Ctrl + H
  • Find what: {.+?(?=<)|(?<=>)[^<>]+}找出什么: {.+?(?=<)|(?<=>)[^<>]+}
  • Replace with: LEAVE EMPTY替换为: LEAVE EMPTY
  • CHECK Match case检查火柴盒
  • CHECK Wrap around检查环绕
  • CHECK Regular expression检查正则表达式
  • UNCHECK . matches newline取消选中. matches newline . matches newline
  • Replace all全部替换

Explanation:解释:

  {         # 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

Screenshot (before):截图(之前):

在此处输入图片说明

Screenshot (after):截图(后):

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM