It is best not to use \1 on the right hand side of a s///. See also "Warning on \1 vs $1" in perlre.
You can omit the escapes to make it a little cleaner: s/(\d+ *)L-homoserine/${1}2-Amino-4-hydroxybutyric acid/;
Also, the match doesn't work for cases with no leading number (you seem to suggest that this is possible). Therefore, something like this might be better: s/(\d*\s*)L-homoserine/${1}2-Amino-4-hydroxybutyric acid/;
--
John.
In reply to Re: Regular expressions Containing Octal values?
by jmcnamara
in thread Regular expressions Containing Octal values?
by arunhorne
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |