Width | Height Regular Expression

J

jpero09

I'm horrible with regular expression and looking for some help.
Searched around and didn't see this one anywhere:
I need a regex to validate a valid height or width.

nnn
nnn% ( ! > 100)
nnn (px | cm)

any help greatly appreciated!!
 
M

Maate

I hope this is any help:

three digits:
\d{3}

between one and three digits:
\d{1,3}

percent number (max 100):
(?:100|\d{1,2})\s?%

px/cm:
\d{1,3}\s?(?:px|cm)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top