[Raleigh-talk] Please assist w/regex

Andy Myhr awmyhr at gmail.com
Tue Mar 20 11:02:26 PDT 2007


Hello all, I am having an issue with regular expressions in Perl.  I  
have the following:

$name = "Sun (TM) Enterprise 250 (2 X UltraSPARC-II 296MHz)";

What I want is:

$name = "Sun Enterprise 250";

But if I use this:

$hwname =~ s/ \(\w+\)//g;

It only removes the "(TM)" portion of the string.  Everything else  
I've tried either does nothing or removes from first "(" to last ")".
Please note, I'm needing a general solution, as $name could contain  
anything, including no "(...)" at all (in which case I'd want to  
leave it untouched).

ThanX!
a.m.



More information about the Raleigh-talk mailing list