Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Problem with regex

    General Discussion
    2
    2
    50
    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.
    • kanishknishar
      kanishknishar last edited by

      This is my text:

      I. Allegro (in B-flat major and in sonata form)
      II. Tema con variazioni (Andante) (theme and 6 variations, where the theme and all the variations are in F major)
      III. Menuetto - Trio (in B-flat major and in ternary form, trio in G minor)
      IV. Adagio (in E-flat major and in sonata form)
      V. Menuetto - Trio (in B-flat major and in ternary form, trio in E-flat major)
      VI. Andante - Allegro molto (in B-flat major, beginning with an introductory instrumental recitative, and in sonata rondo form)
      

      I want to remove all the text that is in parentheses. I wrote a simple regex for it: https://regex101.com/r/z57nQC/1 and it works too (except the last) but when I try it on Notepad++ it finds no matches. What’s going on?

      Terry R 1 Reply Last reply Reply Quote 0
      • Terry R
        Terry R @kanishknishar last edited by Terry R

        @kanishknishar said in Problem with regex:

        and it works too (except the last) but when I try it on Notepad++ it finds no matches. What’s going on?

        Your regex is looking ONLY for \n whereas normally you would use \r\n which refers to carriage return AND line feed, or \R which means any type of line ending, \n, \r or \r\n .\r\n is the normal line ending in a Windows TXT file.

        However the last line will not have these so I’d change your current \n for a $ which means end of line, just before the carriage return and line feed. By not selecting the actual line endings you don’t need to return it as a replacement.

        Terry

        PS you could even use this version of your regex if all the closing brackets finish the line

        1 Reply Last reply Reply Quote 3
        • First post
          Last post
        Copyright © 2014 NodeBB Forums | Contributors