Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

/
^ [ \t]* (?: (?<style> dashed|dotted|double|groove| hidden|(?:in|out)set|inherit| initial|none|ridge|solid ) (?:[ \t]+|[ \t]*(?=$)) ){0,4} [ \t]*$
/
iJxXmg

Description

Validates any border-style value that contains 0-4 (valid) border styles.

Only restriction on whitespace is at least one space/tab between values—all of the examples below are valid:

"solid"
"solid none"
"none none solid"
"outset inset inset solid"
"solid none none"
"solid"
"solid"
"none solid"
"inset             outset   none"
"inset inset outset          none"
Submitted by anonymous - 4 years ago