> I'm looking for a regex (or a couple of regexes) to do the following:
> 
>     blahblah{ab,abcd}blah --> blahblah(ab|abcd)blah
>     blahblah{a,b,c}blah  --> blahblah(a|b|c)blah

Anybody have a faster way to do this?

__CODE__
#!/usr/bin/perl
use strict;
use warnings;

sub uncommify {
  my ($glob) = @_;
  $glob =~ s/,/|/g;
  return $glob;
}

while (<DATA>) {
  chomp();
  print "$_\t->\t";
  s/\{([^}]*?)\}/'('.uncommify($1).')'/ge;
  print "$_\n";
}

__DATA__
blahblah{ab,abcd}blah
blahblah{a,b,c}blah

-- 
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