Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The regular expression in the example above validates the union of the four pieces of logic:

  • 09:.* validates 09:00-09:59

  • 1.:.* validates 10:00-19:59

  • 20:.* validates 20:00-20:59

  • 21:00 validates 21:00

...

Example #2: Validating that a participant inputs a zip code that is 5 numbers ranging from 0-9:

([0-9]{5})

  • [0-9] = a char in range 0-9 (inclusive)

  • {5} = repeat the prior criteria 5 times

Example #3: Validating that a kit ID is either 6 digits or 6 digits with a space in the middle

(e.g., 012 293 or 012293):

[0-9]{3} ?[0-9]{3}

  • [0-9] = a char in range 0-9 (inclusive)

  • {3} = repeat the prior criteria 3 times

  • “ ?” = 0 or 1 spaces (? = match 0 or 1 of the preceding character, which in this case is a blank space)

Example #4: Validating DOB with the format MM/DD/YYYY:

^[0-9]{2}[/][0-9]{2}[/][0-9]{4}$

  • [0-9] = a char in range 0-9 (inclusive)

  • {2} = repeat the prior criteria 2 times

  • {4} = repeat the prior criteria 4 times

  • [/] = insert / symbol

  • ^ . . . $ = complete match in a message (instead of partial match)