Why does my regex numbers match a string like $ab? I want it to only match sequences of decimal digits, 0-9 either followed by a ${ or a $ and followed by a } in the first case and nothing in the second case.
import re
numbers = re.compile('\$\{[0-9]*\}|\$[0-9]*') # ${ANY_SEQUENCE_OF_DIGITS} or $ANY_SEQUENCE_OF_DIGITS
if numbers.match("$ab"):
print 'matches'
This sample code prints 'matches'