Page 1 of 1

Trouble with parentheses in Regular Expressions

Posted: Sat Mar 11, 2006 6:55 pm
by joezeppy
Hi,

I'm trying to search and replace data in a text file using TextPad.

I'd like to replace anything in the file that is between parentheses with a comma.

So

Necturus maculosus (Rafinesque, 1818) Mudpuppy
Necturus punctatus (Gibbes, 1850) Dwarf Waterdog
Necturus punctatus lodingi Viosca, 1937 Mobile Dwarf Waterdog
Necturus punctatus punctatus (Gibbes, 1850) Dwarf Waterdog

Will become

Necturus maculosus , Mudpuppy
Necturus punctatus , Dwarf Waterdog
Necturus punctatus lodingi Viosca, 1937 Mobile Dwarf Waterdog
Necturus punctatus punctatus , Dwarf Waterdog

There are thousands of instances like this.

Any ideas?

I can usually use basic regular expressions but I often get stumped when special characters are part of what I want to replace or delete.

TIA

Posted: Sat Mar 11, 2006 8:14 pm
by s_reynisson
Welcome to the forum joezeppy!

I find life a lot better since I started using POSIX regex's ;)

Find \([^)]*\)
Replace ,
I have used POSIX regular expression syntax, which can be selected from the Editor page of the Preferences dialog box. HTH

I'll give it a try

Posted: Sat Mar 11, 2006 8:33 pm
by joezeppy
Thanks so much.

I'll give it a try.

*Update*

Holy Cow. It worked perfectly.

Thanks so much.

The world is so much better for sharing people like you.

Thanks!

One more thing. Do you think it is a good idea to just keep my TextEdit set to POSIX? (I get that impression from your post).

I'm just wondering if there are any other effects that I should be concerned about. I use TexPad mostly for text and data manipulation, to massage spreadsheets and datafeeds, for normal writing, etc.

BTW, Thanks to TextPad.com!!!! This is the most useful program I have on my computer. I use it often and EVERY DAY. I love it.