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
\nwhereas normally you would use\r\nwhich refers to carriage return AND line feed, or\Rwhich means any type of line ending,\n,\ror\r\n.\r\nis the normal line ending in a Windows TXT file.However the last line will not have these so I’d change your current
\nfor 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
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login