Problem with regex
-
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?
-
@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