[Image of Linux]
The Personal Web Pages of Chris X. Edwards

Regular Expression Tutorial

--------------------------

Optional Quantifier

The optional quantifier, "?", matches the character it's modifying zero or one times. This basically provides a mechanism to have a character be optional.

re-May_07

This will match "May 07" and "May 7".

This will find military time formats.

re-militarytime

Finds "04:33", "21:15", "12:00", "00:00". The optional quantifier allows matches with non-military time such as "8:45" and "2:30". This also means that "0:15" is matched. It will also incorrectly match string such as "27:45". It does not find "30:00", "12:82", etc.

--------------------------
Previous Home Next
This page was created with only free, open-source, publicly licensed software.
This page was designed to be viewed with any browser on any system.
Chris X. Edwards ~ December 2003