Friday, January 13, 2017

Useful REGEXs

^ - says start matching from the beginning of the string.
\d - says match only digits
+ - says match minimum 1 or more occurrences
* - says match minimum 0 or more occurrences
$ - says matching happens until the end of the string.



^\d+$ - Numeric Only

^\D+$ - Characters only


^true$|^false$ - True or False only

^\d+(,\d+)*$ - Comma separated digits only (1,2,3,5)

^\d+(:\d+)$ - Two digits separated by Colon (10:00)

^(\d+(:\d+)(-\d+(:\d+)))$ - Two groups of Two digits separated by colon, connected by a dash (8:00-10:00)



No comments:

Post a Comment