in reply to Re: how to replace a matched pattern in a string with a different pattern of same length?
in thread how to replace a matched pattern in a string with a different pattern of same length?
as I was testing the code I realize, the code that I am using is not matching the longest string of 1's
my $string = '00110011111110111111111111111110'; $string =~ /(1{1,}1)/; print $1, "\n"; prints 11 instead of 11111111111111111
I know to search for longest string separated by 1's, I would use =~ /(1.*1)/, but here "." will pick 0's and 1's both, and I only want 1's. I tried few other combinations but didn't seem to work. any suggestions?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: how to replace a matched pattern in a string with a different pattern of same length?
by roboticus (Chancellor) on Jun 19, 2011 at 14:42 UTC | |
|
Re^3: how to replace a matched pattern in a string with a different pattern of same length?
by BrowserUk (Patriarch) on Jun 19, 2011 at 15:56 UTC |