I have a string:
# print thestring
abcd\t$500\n
I want to extract the dollar value of 500 without the dollar sign.
Here is my code:
# trying positive lookbehind
m = re.search('(<=\$)\d+$',thestring)
# trying passive groups
m = re.search('(?:\$)\d+$',thestring)
What am I doing wrong here?
Non-capturing groups do not remove the result from the matched substring, so that’s why the second solution didn’t work. The first solution should work, but you seem to have mistyped the syntax for a positive lookbehind. It should be: