Ok....

while (<DATA>){

        print;
        print "becomes\n";
        s/\([^\(\)]+\)|\(\(\)\)/()/g;
        print;
        print "\n";

}
__DATA__
asdf(asdf)asdf
asdf((asdf))asdf
asdf(as(asdf)df)asdf

--------prints------

asdf(asdf)asdf
becomes
asdf()asdf

asdf((asdf))asdf
becomes
asdf(())asdf

asdf(as(asdf)df)asdf
becomes
asdf(as()df)asdf

--------- so, while what? ---------



-----Original Message-----
From: Joseph P. Discenza [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 07, 2001 8:53 AM
To: Ron Hartikka; perl win32 users
Subject: RE: RegEx: Finding and replacing all characters between ( and )
?


Ron Hartikka wrote, on Thursday, June 07, 2001 8:33 AM
: Can the () in your data be nested?
:
: If so, you can't use an re. (See: How do I find matching/nesting anything?
: in perlfaq 4.) For example,
:
: while (<DATA>){
:
:       print;
:       print "becomes\n";
:       s/\([^\)]+\)/()/g; # as Bill suggests

What if you make it
        s/\([^\(\)]+\)|\(\(\)\)/()/g;
? You could also stick that in a while, print it at each iteration,
and watch the innermost parenthetical expressions disappear.

Joe

==============================================================
          Joseph P. Discenza, Sr. Programmer/Analyst
               mailto:[EMAIL PROTECTED]

          Carleton Inc.   http://www.carletoninc.com
          219.243.6040 ext. 300    fax: 219.243.6060

Providing Financial Solutions and Compliance for over 30 Years



_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

Reply via email to