Community
    • Login

    What standard for Regular Expressions is Notepad++ using?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    5 Posts 3 Posters 6.5k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Tony De GrootT
      Tony De Groot
      last edited by

      Hi,
      I have been using Notepad++ for occasional general editing for a couple of years, and find it very useful.

      I am starting to explore regular expressions but I have no reference for the regular expression terms or syntax. Can someone point me at a reference for the regular expressions used in Notepad++?

      My baseline for Regular Expressions is on Edit/1000 under RTE/A for HP Minicomputers (1985) and early HPUX, but nothing for the last 20 ish years as I only dabble in Unix/Linux … I saw the syntax change quickly in the early days but do not know if it has stabilised into a common format by now …

      Thanks,
      Tony.

      1 Reply Last reply Reply Quote 0
      • Scott SumnerS
        Scott Sumner
        last edited by

        You will find an exhaustive discussion of the Notepad++ regular expression “flavor” here:
        https://notepad-plus-plus.org/community/topic/9703/is-it-planned-to-switch-to-pcre2

        Perhaps that contains a deeper treatment than you want/need. Basically N++ currently uses the BOOST implementation, and these TWO links, which are buried in the above link, are very helpful in understanding Notepad++'s regexes:

        SEARCHING:
        http://www.boost.org/doc/libs/1_55_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html

        REPLACING:
        http://www.boost.org/doc/libs/1_55_0/libs/regex/doc/html/boost_regex/format/boost_format_syntax.html

        1 Reply Last reply Reply Quote 0
        • Tony De GrootT
          Tony De Groot
          last edited by

          Hi Scott,

          Thanks for the help.

          I have all my editting done except for deleting lines.

          From the command line I would use something like:
          1$f/^“”/,d
          to search the file, find all occurrences of 2 quotes at the start of a line, and then delete that line. Repeat until end of file.

          I cannot see if there is a facility to drop into a command line, nor can I find a delete option in the Search/Replace menu.

          Can you tell me what I am missing?

          Thanks,
          Tony

          1 Reply Last reply Reply Quote 0
          • guy038G
            guy038
            last edited by

            Hello Tony,

            You can get this action, by two means, with Notepad++ :

            • by performing a simple Search and Replace operation, in regular expression mode

            • by deleting all the bookmarked lines, which contain two double quotes, at the beginning of each line


            First method :

            • Open the Replace dialog ( CTRL + H )

            • SEARCH ^"".*\R

            • REPLACE Nothing

            • Check the Wrap around option

            • Check the Regular expression search mode ( Important )

            • UNCHECK the .matches newline option, if necessary

            • Click on the Replace All button

            Notes :

            • ^ is an assertion, that represents the location between the last EOL character of the previous line and the first character of the current line

            • .* then matches the rest of the line, after the two double quotes

            • \R stands for any kind of EOL characters ( \r\n, for Windows files, \n, for Unix files or \r for old Mac files )

            • As the replacement zone is empty, then, the entire lines, containing "", at beginning of lines are deleted


            Second method :

            • Open the Mark dialog ( Menu Search - Mark… )

            • SEARCH ^""

            • Check the Bookmark line option

            • Check the Wrap around option

            • Check the Regular expression search mode ( Important )

            • UNCHECK the .matches newline option, if necessary

            • Click on the Mark All button

            • Select the menu option Search - Bookmark - Cut Bookmark Lines

            Best Regards,

            guy038

            1 Reply Last reply Reply Quote 0
            • Tony De GrootT
              Tony De Groot
              last edited by

              Hi guy038,

              I had used part of your first example - I used search for ^“”, but missed the rest of the line. Using the complete expression worked fine.

              Many thanks,

              Tony

              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors