Apr 15, 2010, 1:29 AM
Post #1 of 2
Replacing all occurrences of something in a part of a string
I wonder if it is possible to write a regular expression that replaces all occurrences of something (e.g. whitespace), but not in the whole string, but a part of a string that is identified by some matched characters.
In my particular example, I would like to replace all spaces with underscores between an opening and a closing parenthesis (possibly with multiple occurrences of (...) in the line).
"bla bla (this is some stuff in parens) bla (and again) bla" -> "bla bla (this_is_some_stuff_in_parens) bla (and_again) bla"