Replacing an opening parenthesis by an opening parenthesis with a space directly after

Find, replace, find in files, replace in files, regular expressions

Replacing an opening parenthesis by an opening parenthesis with a space directly after

Postby corvannoorloos » Thu Nov 01, 2012 8:22 am

My program version: 18.20.0.1020
My operating system: Windows 7 Home Premium SP1 64-bit

Hello,

I'm currently looking for a way to replace an opening parenthesis by an opening parenthesis with a space directly after.
Now this would be an easy search + replace action. No expressions needed.
However, if possible, I'd like to skip the opening parenthesis already containing a space directly after.

As an example:
Code: Select all
remove_filter('term_description', 'wpautop');

to
Code: Select all
remove_filter( 'term_description', 'wpautop');

or preferably
Code: Select all
remove_filter( 'term_description', 'wpautop' );

I've been trying to solve this using Google, the search function, and Expresso. Unfortunately without any luck thus far.

Would someone be able to assist here perhaps?

Best Regards,

Cor
corvannoorloos
Newbie
 
Posts: 1
Joined: Thu Nov 01, 2012 7:58 am

Re: Replacing an opening parenthesis by an opening parenthesis with a space directly after

Postby Mofi » Thu Nov 01, 2012 11:19 am

With the UltraEdit regular expression engine search for (^([~ ^t^r^n]^) and use as replace string ( ^1

This is a tagged regular expression searching for an opening parenthesis followed by a character which is NOT a space, tab, carriage return or line feed.

But you need to run this UltraEdit regular expression Replace All several times until nothing replaced anymore in case there are multiple opening parenthesis in a sequence.

For the closing round parenthesis search for ^([~ ^t^r^n]^)) and use as replace string ^1 )

Also this Replace All must be executed until nothing replaced anymore.

Easier would be to simple run a non regular expression Replace All searching for ( and replacing with ( and a space character. Next run a Replace All searching for ( with 2 spaces and use as replace string ( with a single space. This results with just 2 Replace All in the wanted style for opening parenthesis. Next run a non regular expression Replace All searching for ) and replacing with a space charachter and ). Last run a Replace All searching for 2 spaces and ) and use as replace string a single space and ).
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 3937
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Find/Replace/Regular Expressions