On Jul 26, 2004, at 8:17 PM, Ian Marlier wrote:

Hi, all --

I've got another RegEx question, a follow-up to one that I asked earlier
today:


Given a string that looks like this:
"This is a (string of words) that go together"

I need to turn it into this:
"This is a (stringofwords) that go together"

Which is to say, I need to match one set of characters (the parentheses) and
then do a reg-ex operation on another (the spaces).


Thoughts?

Do you have to worry about nested parens? It's a lot easier if you don't:


s{(\([^)]\))}{
        my $replace = $1;
        $replace =~ tr/ //d;
        $replace;
}e;

Hope that helps.

James


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to