Need some help with regular expressions. I want to match some Roman numerals and replace them to arabic.
First of all if use (IX|IV|V?I{0,3})
to match roman numerals (from 1 to 9).
Then i add some logic to either space (with some text before) or nothing (begin/end of string) with (?:^|\s)(?:\s|$)
So finaly i've (?:^|\s)(IX|IV|V?I{0,3})(?:\s|$)
It matches all this variants:
- some text VI
- IX here we are
- another III text
If i define dict with roman-arabic map {'iii': 3, 'IX': 9}
- how to repalce matches with values from dict? Also it matches only first accur, i.e. in some V then III
i get only V