I am trying to extract a sub-string from a string using regular expressions. Below is the working code in Python
(giving desired results)
Python Solution
x = r'CAR_2_ABC_547_d'
>>> spattern = re.compile("CAR_.*?_(.*)")
>>> spattern.search(x).group(1)
'ABC_547_d'
>>>
Perl Solution
$ echo "CAR_2_ABC_547_d" | perl -pe's/CAR_.*?_(.*)/$1/'
ABC_547_d
TCL Solution
However, when I try to utilize this approach in Tcl
, it is giving me different results. Can someone please comment on this behavior
% regexp -inline "CAR_.*?_(.*)" "CAR_2_ABC_547_d"
CAR_2_ {}