in reply to Re: regexp - replace spaces in quoted string
in thread regexp - replace spaces in quoted string
I didn't write the original post, but I was thinking about doing it a different way, although this one seems to be#declarations my ($quote_on,$output); #default scalar is the data $_ = q/this is a "test of some regexp" blah blah this is another "test of some regexp" foo bar/; #using $_ begin a for loop performing a split on each #element for (split //) { #quote_on is a boolean set to true when the increments reach #a quote (and then off again when reaching another quote) $quote_on = ($quote_on ? 0 : 1) if (/\"/); #if processing elements after a quote, then replace the #whitespace with an underscore s/\s/_/g if $quote_on; #assign all that to $output $output .= $_; }
|
|---|