regex –make option

Get a ready regex

The –make option is described by its author as “a remedy for headaches.” It outputs a regexp for one of several common patterns that are given as arguments, as listed in table**.**

List of ready regexps available in txt2regex

<th scope="col" align="left">
  Description
</th>
<td>
  This argument matches dates in mm/dd/yyyy format, from 00/00/0000 to 99/99/9999.
</td>
<td>
  This argument matches dates in mm/dd/yyyy format, from 00/00/1000 to 19/39/2999.
</td>
<td>
  This argument matches dates in mm/dd/yyyy format, from 00/00/1000 to 12/31/2999.
</td>
<td>
  This argument matches time in hh:mm format, from 00:00 to 99:99.
</td>
<td>
  This argument matches time in hh:mm format, from 00:00 to 29:59.
</td>
<td>
  This argument matches time in hh:mm format, from 00:00 to 23:59.
</td>
<td>
  This argument matches any positive or negative integer.
</td>
<td>
  This argument matches any positive or negative integer with an optional floating-point value.
</td>
<td>
  This argument matches any positive or negative integer with optional commas and an optional floating-point value.
</td>
Argument
date
date2
date3
hour
hour2
hour3
number
number2
number3

For example, you can use this to get a ready regexp for any valid hour in military time, as shown in listing.

Listing. Getting a date regexp with txt2regex

$ txt2regex --make hour3
RegEx perl    : ([01][0-9]|2[0123]):[012345][0-9]
RegEx php     : ([01][0-9]|2[0123]):[012345][0-9]
RegEx postgres: ([01][0-9]|2[0123]):[012345][0-9]
RegEx python  : ([01][0-9]|2[0123]):[012345][0-9]
RegEx sed     : ([01][0-9]|2[0123]):[012345][0-9]
RegEx vim     : ([01][0-9]|2[0123]):[012345][0-9]

$