正则表达式使用记事本++查找双括号 [英] Regex to find double parenthesis using Notepad++

查看:177
本文介绍了正则表达式使用记事本++查找双括号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试寻找在另一句中有开括号和闭括号的句子,例如(text(more)).我尝试了以下类似的\([^\)].*?\(-\(.*\(-((?:\([^]]*\))+)来匹配至少前两个((,但这是不对的,我认为最好将((.*))匹配为懒惰的量词,并且它应该与(())之间的文本中的任何内容一起使用,即使它像html代码一样在行之间进行分割.等

I am trying to find sentences that has opening and closing parenthesis within another one, like (text (more)) . I tried something like the following \([^\)].*?\( - \(.*\( - ((?:\([^]]*\))+) to match at least the first two (( but it's not right, and I think it would be better to match something like ((.*)) with a lazy quantifier, and it should work with anything in the text between the (()), even if it is divided between lines like in html codes. etc.

示例文字:

知道我可以(否定)字符组知道我可以否定字符组知道我可以否定字符组知道我可以 取反字符组aknow(我可以取反)((chars 知道))我可以否定一组字符知道我可以否定 ((字符组)(知道))我可以否定字符组,但可以否定字符组,但可以否定字符组 chars知道我可以否定一组chars知道我可以否定一组 一组字符知道我可以否定一组字符知道我 可以否定((一组字符,我知道可以否定)) 字符

know that I can (negate) group of chars aknow that I can negate group of chars aknow that I can negate group of chars aknow that I can negate group of chars aknow (that I can negate) group of ((chars aknow that)) I can negate group of chars aknow that I can negate (group (of chars) (aknow) that) I can negate group of chars aknow that I can negate group of chars aknow that I can negate group of chars aknow that I can negate group of chars aknow that I can negate group of chars aknow that I can negate group of chars a know that I can negate ((group of chars a know that I can negate)) group of chars a

确认我可以否定组(字符),知道我可以否定#e g [roup]个字符

确认知道我可以否定(chars aknow)组

aknow that aknow that I can negate group of (chars aknow)) that I can negate group of chars aknow that

推荐答案

您可以使用

\([^()]*(?:(?R)[^()]*)+\)

设置:

详细信息

  • \(-一个(字符
  • [^()]*-()
  • 以外的0个字符
  • (?:(?R)[^()]*)+-重复1次或更多次
    • (?R)-整个模式都被递归
    • [^()]*-()
    • 以外的0个字符
    • \( - a ( char
    • [^()]* - 0+ chars other than ( and )
    • (?:(?R)[^()]*)+ - 1 or more repetitions of
      • (?R) - the whole pattern is recursed
      • [^()]* - 0+ chars other than ( and )

      这篇关于正则表达式使用记事本++查找双括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆