Menu

Why doesn't this regex work?

2006-01-16
2012-11-13
  • Johan Larsson

    Johan Larsson - 2006-01-16

    reg(ular expressions?|ex(p|es)?)

    I'm just started to look at regular expressions, and trying the tutorial at http://www.regular-expressions.info/tutorial.html , but that first test-search doesn't work in np++... ("Now try to search using the regex reg(ular expressions?|ex(p|es)?) This regex will find all names, singular and plural, I have used on this page to say 'regex'.")

    Other, more simple, examples I tried with np++ works.

    That tutorial is written by the author of EditPad Pro (in which the above search works) - is he making use of some non-standard/windows only implementations? (If there is such a thing... ?)

     
    • Johan Larsson

      Johan Larsson - 2006-01-16

      Ok, I've found something pointing to that there are differences in syntax in different tools... :-\ http://sitescooper.org/tao_regexps.html#Regular_Expressions_In_Various_Tools I hoped I'd be gaining some universal knowledge! :) Which syntax does np++ use?

       
      • Paulius

        Paulius - 2006-01-16

        Notepad++ uses Scintilla component. Scintilla component has its own implementation of regular expressions, which is a (very) small subset of features supported by POSIX regular expressions.

        You can find more information about Scintillas regular expression syntax here: http://scintilla.sourceforge.net/ScintillaDoc.html#Searching

         
        • Paulius

          Paulius - 2006-01-16

          Forgot to mention, that in Notepad++ SCFIND_POSIX flag is always set - this flag is also documented on that page.

           
        • Nobody/Anonymous

          (keywords: POSIX, regex, expressions)

          Why not just implement full POSIX expressions?
          Now i have top open up another editor each time i want to work with regular expressions, since most semi-advanced features don't work, or not as expected.

           
          • pshute

            pshute - 2007-09-28

            It would be nice.  Is there just a particular operation you want to do?  Maybe there's another way.

             
            • Nobody/Anonymous

              Scintilla's developers don't want to do that.
              https://sourceforge.net/tracker/index.php?func=detail&aid=1696579&group_id=2439&atid=352439

              Interesting, is it possible to implement a powerfull regex engine like PCRE as a plugin? All that needed for that is to get the text in editor as a long zero-terminated string... But it's not possible in scintilla afaik? Only possiible to copy whole the text to a temporary buffer, but for big files it'll be slow and consume a lot of memory... Or to change PCRE routines so that they use scintilla's Accessor* clases to get characters from the editor...