Matt, you can do it also with split but you have to join the parts back together after changing the part you want.Unmatched ) in regex; marked by <-- HERE in m/ [A-Z]+ # WB \(\d+,\d+) <-- HERE # (1,2) \s*=\s* # = (?: # start non-capturing group \d+\.\d+, # a float followed by comma \s*(\d+\.\d+),? # capture a float (followed by comma?) ) # end-group / at /tmp/wb line 10.
$_ = 'WB(1,2)= 0.000, 1.23, TB(1,2)= 0.0, 253.0, TMB(1,2)= 0. +0, 1.0, SL(1,2)= 0.00, 1.00'; my @parts = split /, /; $parts[1] = 3.21; # change 1.23 with 3.21 $_ = join ', ', @parts; print $_, "\n"; # output: # WB(1,2)= 0.000, 3.21, TB(1,2)= 0.0, 253.0, TMB(1,2)= 0.0, +1.0, SL(1,2)= 0.00, 1.00
Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!
In reply to Re^2: parsing a line of text with inconsistent delimiters
by naikonta
in thread parsing a line of text with inconsistent delimiters
by mattgarrett
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |