XPages site addressing modern Domino
TwitterFacebookGoogleLinkedInEmail

Regular Expressions

Using regular expressions to find common text patterns.

Problem Solution Comments
Find IP Address /(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/g Takes in consideration leading zero, no leading zero and up to 255
Match Dates ^\d{4}[-/](0?[1-9]|1[0-2])[-/](0?[1-9]|[12][0-9]|3[01])\b limit month to 12, and days up to 31
2000-01-30
2016/5/9
Match Written Dates (January|February|March|April|May|June|July|August|September|October|November|December) (0?[1-9]|3[0-1])\b, \d{4} January 30, 2016
Match Time ^([01]?[0-9]|1[0-9]|2[0-3]):[0-5][0-9](pm|PM|am|AM)?(:[0-5][0-9])?( [A-Z]{3})?$ 2:30
12:41
3:30 pm
23:00:34 EST
Match Password Requirement ^(?=.*\d)(?=.*[~!@#$%^&*()_\-+=\\|{}[\]])(?=.*[A-Z])(?=.*[a-z])\S{8,15}$ May contain any character except space
At least eight characters long
Must include at least one uppercase letter
Must inlcude at least one lowercase letter
Must include at least one numeric digit
Must include at least one symbol
Match Major Credit Cards ^(?:3[47]\d{2}([\- ]?)\d{6}\1\d{5}|(?:4\d{3}|5[1-5]\d{2}|6011)([\- ]?)\d{4}\2\d{4}\2\d{4})$ American Express
370012345612345
3400-123456-12345Visa
4000123412341234
4000-1234-1234-1234

Mastercard
5100123412341234
5100-1234-1234-1234

Discover
6011123412341234
6011-1234-1234-1234

Find Words \b[A-Za-z]+\b Does not include punctuations