Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
ECMAScript (JavaScript)

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

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 disk0 <www.github.com/disco0> - 4 years ago