OK, heres a weird one I came across.
I have a list of chemical names; something like:
3 L-homoserine 1 L-iditol
As is the way with chemical names they have lots of synonyms and so I am replacing these with regular expressions. My problem arises because there may be an arbitrary numerator in front of the chemical name (as they came from a formula)... this needs to be preserved as the formulas will be rebuilt.
The synonym for L-iditol is L-Iditol (just a case change) so this is fine being replaced by:
s/(\d+ *)L\-iditol/\1L\-Iditol/
Simple and works... however the synonym for L-homoserine is infact 2-Amino-4-hydroxybutyric acid.
So I write the regex:
s/(\d+ *)L\-homoserine/\12\-Amino\-4\-hydroxybutyric\ acid/
When applied to L-homoserine I get a blank line then '-Amino-4-hydroxybutyric acid' (note the missing 2). Note that in the regular expression the replacement string begins \12 . The \1 bit includes the numerator (3 in the above example) but the 2 is actually part of the new string. When combined they don't work like this. I consulted by table of ascii values and find that \012 is infact the code for newline...
Has anyone had this problem before? How can I force \12 to behave as I want it rather than producing a new line?
Looking forward to resolving this strange one.
Arun
In reply to Regular expressions Containing Octal values? by arunhorne
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |