Regular expression visualizer

Visualize regular expressions as railroad diagrams — modern syntax, live preview.

/
/
/(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/Group #1: year4 times\dDigit-Group #2: month2 times\dDigit-Group #3: day2 times\dDigit

Explanation

  • (?<year>\d{4})capturing group #1 (named "year"):
  • \d{4}repeated exactly 4 times:
  • \da digit (0-9)
  • -the character "-"
  • (?<month>\d{2})capturing group #2 (named "month"):
  • \d{2}repeated exactly 2 times:
  • \da digit (0-9)
  • -the character "-"
  • (?<day>\d{2})capturing group #3 (named "day"):
  • \d{2}repeated exactly 2 times:
  • \da digit (0-9)

Test strings

/(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/.test(str)

JS code

const re = /(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/

if (re.test(str)) {
  // matched
}

Examples