Solve the programming task below in a Python markdown code block.
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`.
Also feel free to reuse/extend the following starter code:
```python
def to_cents(amount):
```