Implement `String#to_cents`, which should parse prices expressed as `$1.23` and return number of cents, or in case of bad format return `nil`.
import re

def to_cents(amount):

    if not re.match(r"^\$(0|[1-9]+\d*)\.\d{2}\Z", amount):
      return None
      
    return int(re.sub(r"[\$\.]", "", amount))
import re

def to_cents(amount):

    if not re.match(r"^\$(0|[1-9]+\d*)\.\d{2}\Z", amount):
      return None
      
    return int(re.sub(r"[\$\.]", "", amount))