Menu

very basic lazy regex not supported?

2009-03-12
2012-11-13
  • Leon Sorokin

    Leon Sorokin - 2009-03-12

    name=".*?"

    are lazy operators "?" not supported at all?

    i tried a repetition workaround which also failed: name=".{0,20}"

    both of these regex constructs are extremely basic. without them regex becomes unusably clumsy. any chance to upgrade to scintilla v1.77 and utilize the new temp text buffer access for injecting proper regex support?

    thanks,
    Leon

     
    • Fool4UAnyway

      Fool4UAnyway - 2009-03-12

      Would just "lazy" be good enough?

      name="[^"]*"

      Suggestion: search the forums about regex and possibly greedy.

       
      • Fool4UAnyway

        Fool4UAnyway - 2009-03-12

        Or read this:

        Copied from:

        http://www.regular-expressions.info/quickstart.html

        >> "
        Greedy and Lazy Repetition
        The repetition operators or quantifiers are greedy. They will expand the match as far as they can, and only give back if they must to satisfy the remainder of the regex. The regex <.+> will match <EM>first</EM> in This is a <EM>first</EM> test.

        Place a question mark after the quantifier to make it lazy. <.+?> will match <EM> in the above string.

        A better solution is to follow my advice to use the dot sparingly. Use <[^<>]+> to quickly match an HTML tag without regard to attributes. The negated character class is more specific than the dot, which helps the regex engine find matches quickly.

        Learn more about greedy and lazy quantifiers
        http://www.regular-expressions.info/repeat.html#greedy
        " <<

         
    • Greg

      Greg - 2009-03-12

      RegEx in N++ does not support repeats ?  or {x,y}.  It means we have to be smarter about how we use RegEx. One thing to consider is making several passes.

      We all want improvements to the RegEx functionality but at the moment all we have is what Scintilla provides.