Page 1 of 1

regex: replace )\n with \n\n

Posted: Mon Oct 14, 2024 9:12 am
by gcotterl
I want to replace )\n with \n\n

Since \n is a regular expression, “Regular Expression” is ticked on the “REPLACE” screen.

The “FIND WHAT” box contains: )\n
The “REPLACE WITH” box contains: \n\n

When I click any of the “REPLACE” buttons, a dialog box is displayed saying “Found a closing ) with no corresponding opening parentheses. The error occurred while parsing the regular expression: ‘>>>HERE>>>)’”.

How do I make the above replacement?

Will the above dialog box be displayed for any other characters? If “yes”, what are they?

Re: Dialog box

Posted: Mon Oct 14, 2024 10:17 am
by bbadmin
Brackets are special characters in regular expressions so you must escape them with a backslash if they are to match literal brackets.

Re: Dialog box

Posted: Mon Oct 14, 2024 11:05 am
by gcotterl
so, in my example, "Find What" would be \)\n ?

Re: Dialog box

Posted: Mon Oct 14, 2024 11:33 am
by bbadmin
Yes, that's correct. Lookup regular expressions in the help file for a list of the special characters.

Re: regex: replace )\n with \n\n

Posted: Mon Oct 14, 2024 1:52 pm
by gcotterl
Thanks, I will do that.

BTW: I don't know if there's a way to mark this thread as wonderfully resolved nor how to close this item. Can you do it for me?