Regular Expressions | ||||
---|---|---|---|---|
Function | Regular Expression | Will match | Remarks | |
Fully qualified path | (("?)[A-Z]:(\\[^:\\"\n\r]+)*\\?\2) | Any local path | May break on ampersands | |
Fully qualified path | ("[A-Z]:(\\[^:\\"\n\r]+)*\\?"|[A-Z]:(\\[\w_-\.]+)*\\?) | Any local path | ||
Fully qualified path | ("([A-Z]:|\\\\[\w_-\.]+\\[\w_-\.]+)(\\[^:\\"\n\r]+)*\\?"|([A-Z]:|\\\\[\w_-\.]+\\[\w_-\.]+)(\\[\w_-\.]+)*\\?) | Any local or UNC path | ||
Simple date | ([0-9]{1,2}[-/][0-9]{1,2}[-/]([0-9]{2})?[0-9]{2}) | Any date | Will match 99/99/9999 or 00-00-00 | |
Date (MM/DD/YYYY) | ((0?[1-9]|1[0-2])/(0?[1-9]|[12][0-9]|3[01])/[12][0-9]{3}) | Date in current or previous millennium | Will match 2/31/2010 | |
Date (DD-MM-YYYY) | ((0?[1-9]|[12][0-9]|3[01])-(0?[1-9]|1[0-2])-[12][0-9]{3}) | Date in current or previous millenium | Will match 31-2-2010 | |
Simple time | ([0-9]{1,2}:[0-9]{2}(:[0-9]{2}(\.[0-9]+)?)?) | Any time | Will match 99:99:99.999 | |
Time (24h) | (([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9](\.[0-9]+)?)?) | True time | Will only match valid times in 24h notation, with seconds and fraction of seconds optional | |
Time (AM/PM) | ((0?[0-9]|1[0-2]):[0-5][0-9](:[0-5][0-9](\.[0-9]+)?)? ?([AaPp][Mm]?)?) | True time | Will only match valid times in AM/PM notation, with seconds, fraction of seconds and AM/PM/A/P optional and case insensitive | |
E-mail address | ([\w-\.]+\@([\w-]+\.)+[\da-zA-Z]{2,4}) | Valid e-mail address | Will also find a match even in invalid numerical top level domains; when an e-mail address is valid, it doesn't necessarily mean it exists. | |
Simple HTML tag | (<[ˆ>]+>) | Any tag in HTML code | Will fail on <img src="fastforward.gif" alt=">>"> | |
HTML tag with embedded text | (<[ˆ>]+>([ˆ<]+<\/[ˆ>]+>)?) | Single tag only or "tag set" including attributes | Will also fail on <img src="fastforward.gif" alt=">>"> and on nested HTML tags, e.g. <b><i>text</i></b> | |
HTML tag with embedded text | (<[ˆ>\"]+([ˆ\">]+=\"[ˆ\"]*\" *)*>([ˆ<]+<\/[ˆ>]+>)?) | Single tag only or "tag set" including attributes | Will fail on nested tags, e.g. <b><i>text</i></b> and doesn't detect incorrect tag sets, e.g. <b>text</i> | |
HTML tag with embedded text | (<([ˆ\/\s>\"])+(\s+[ˆ\">]+=\"[ˆ\"]*\"\s*)*>(.+<\/\2>)?) | Single tag only or "tag set" including attributes | Does not detect improperly nested tags, e.g. <b><i>text</b></i> | |
Simple IP (v4) address | (([0-9]{1,3}\.){3}[0-9]{1,3}) | Any IP (v4) address | Will match 999.999.999.999 | |
IP (v4) address | (([0-2]?[0-9]{1,2}\.){3}[0-2]?[0-9]{1,2}) | Any IP (v4) address | Will still match 299.299.299.299 | |
True IP (v4) address | ((([01]?[0-9]{1,2}|2([0-4][0-9]|5[0-5]))\.){3}([01]?[0-9]{1,2}|2([0-4][0-9]|5[0-5]))) | True IP (v4) address | Will only match valid IP addresses, does accept leading zeroes |
page last modified: 2023-12-04; loaded in 0.0015 seconds