def dollars_to_cents(s, allow_negative=False):
<EOL>if not s:<EOL><INDENT>return<EOL><DEDENT>if isinstance(s, string_types):<EOL><INDENT>s = '<STR_LIT>'.join(RE_NUMBER.findall(s))<EOL><DEDENT>dollars = int(round(float(s) * <NUM_LIT:100>))<EOL>if not allow_negative and dollars < <NUM_LIT:0>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>return dollars<EOL>
Given a string or integer representing dollars, return an integer of
equivalent cents, in an input-resilient way.

This works by stripping any non-numeric characters before attempting to
cast the value.

Examples::

    >>> dollars_to_cents('$1')
    100
    >>> dollars_to_cents('1')
    100
    >>> dollars_to_cents(1)
    100
    >>> dollars_to_cents('1e2')
    10000
    >>> dollars_to_cents('-1$', allow_negative=True)
    -100
    >>> dollars_to_cents('1 dollar')
    100