Matching any certain selection of inputs
You can combine px and em into a single group
You can pull in the negation sign with a ?
[0-9] is equivalent (usually) to \d
^ and $ can be pulled out to the end (or use the api than only matches the entire string.


this results in:

^(-?\d+(px|em)|\d+%|auto|0)$


If you can have a negative % values then it's even simpler: ^(-?\d+(px|em|%)|auto|0)$