Menu

Multiline regular expressions

2008-03-16
2012-11-13
  • Nobody/Anonymous

    Do you happen to have a plan to support multiline regular expressions such as \r and \n in the near future?

     
    • pshute

      pshute - 2008-03-17

      I know this doesn't answer your question, but http://notepad-plus.wiki.sourceforge.net/FindReplaceNewlineHowTo discusses some non-regex workarounds for find/replace.  If you really need regex then you might be able to do what you want in two stages.

       
      • Nobody/Anonymous

        Just two remarks when taking a quick look at this wiki:

        1. I can't believe that for such a common feature a totally different approach is mentioned first. Does anyone know what a Hex editor is? If this would be the way to go, then just throw away the find/replace dialogs. If you want to be informative, just add such a topic at the end of the regular explanation. If I am cycling and asking someone "How can I get there?" I am not curious to hear that I get there fastest by train.

        2. "$ matches newlines" is technically not correct. It would be better to state that ^ matches newlines, because this precedes newlines. So it will always be found when searched for. Will $ be matched for the last line if it has no linebreak?

         
        • Nobody/Anonymous

          > Just two remarks when taking a quick look at this wiki:

          > 1. I can't believe that for such a common feature a totally different approach is mentioned first. Does anyone know what a Hex editor is? If this would be the way to go, then just throw away the find/replace dialogs. If you want to be informative, just add such a topic at the end of the regular explanation. If I am cycling and asking someone "How can I get there?" I am not curious to hear that I get there fastest by train.

          > 2. "$ matches newlines" is technically not correct. It would be better to state that ^ matches newlines, because this precedes newlines. So it will always be found when searched for. Will $ be matched for the last line if it has no linebreak?

          Wow.  Let me jump in here.  I don't know that much about N++ but I certainly know what a hex editor is (my God, N++ is a "programmer's editor" too).  Advice: take a train.

          ^ isn't going to solve the problem anymore than $

          Please take the train.

           
        • pshute

          pshute - 2008-03-18

          > 1. I can't believe that for such a common feature a totally different approach is mentioned first.

          Yes, the original article has been butchered a little.  I just move that method to the bottom.

          > 2. "$ matches newlines" is technically not correct.

          Maybe.  When I wrote the original article there was very little information around about what would and wouldn't work, so I was guessing a bit.  What I've written in the article works, and that's the important thing.  If you want to fix it up then you're welcome, just so long as your thoroughly test anything you suggest people do first.  There's no point being technically correct if Notepad++ doesn't work that way.

          Would ^ be found if the last line has no newline after it?

          I haven't kept my copy of Notepad++ at the very latest version, so some later versions might operate a little differently.  I think there was a Scintilla update recently, so if anyone can confirm that it works differently, please update this page of the wiki, preferably retaining the original and adding a note mentioning which version works differently.

           
        • Nobody/Anonymous

          > 2. "$ matches newlines" is technically not correct. It would be better to state that ^
          > matches newlines, because this precedes newlines. So it will always be found when
          > searched for. Will $ be matched for the last line if it has no linebreak?

          > matches newlines

          This was intended to be new lines instead of newline( character)s, of course.

          > Will $ be matched for the last line if it has no linebreak?

          Yes, this also seems to be matched for the last line if there is no linebreak character.

           
    • Nobody/Anonymous

      Thank you very much for the useful information.