Regular Expressions 101

Community Patterns

CSS Length Units

3

Regular Expression
PCRE (PHP <7.3)

/
^(-?\d+(em|ex|%|px|cm|mm|in|pt|pc|ch|rem|vh|vw|vmin|vmax)|0)$
/
i

Description

Matches CSS Length Units according to: http://www.w3schools.com/cssref/css_units.asp

Submitted by Sander Backus - 8 years ago