<< < 1 2 3 4 5 6 > >>   Sort: Date

Discover credit card number validation
All credit card numbers issued by Diners Club must start with 6011 or 65 and have 16 digits. For example, 6011186767363105 is a valid Visa credit card number. How to write a single regular expression to validate a Discover credit card number described above? Here is the regular expression to validat...
2013-01-22, 2138👍, 0💬

Does negative character class match newline
Does negative character class [^a] match newline characters? How to write a regular expression to capture tags and attributes from this HTML code: A negative character class will match the newline character, if the newline character is not listed in the class. For example, "[^a]" will match the newl...
2013-02-02, 2134👍, 0💬

Parsing header lines of an email message
How write a regular expression to capture all header lines from an email message like this: Return-Path: X-Original-To: test@example.com Delivered-To: test@example.com Message-ID: Date: Thu, 23 Jun 2011 11:26:29 +0200 From: Example Sender To: Example Receiver Subject: Email example Hello Joe, It was...
2013-02-01, 2134👍, 0💬

Validating Complexity and Length of Passwords
How to write a regular expression to check the complexity and length of passwords with the following requirements: Password must be at least 6 characters long Password must include at least including 1 upper case letter Password must include at least including 1 lower case letter Password must inclu...
2013-01-29, 2130👍, 0💬

Capturing fragment id from URL
How to capture fragment id from URL addresses with a regular expression? Here are URL address examples:ftp://ftp.example.org /https://login.example.com:5800 /?mode=guest&lang=enhttp://www.google.com:80/api/e xample/submit.php?name=joe#newfile://localhost/c|/WINDOWS/do cument.html#chapter1URL add...
2013-02-03, 2109👍, 0💬

Positive look-ahead assertion (?=...)
What is a positive look-ahead assertion? How to use it? How to write a regular expression to find words with 'oo' in text like: how, to, look, google, school? A positive look-ahead assertion is a zero-width assertion that allows you to match a subpattern beyond the current position (look-ahead) with...
2013-01-26, 2104👍, 0💬

Logical OR (Alternation) operation (a|b)
What is a logical OR operation? How to specify a logical OR operation in a regular expression? How to use logical OR operations to build a regular expression to search and count common spamming terms from this email paragraph: I am inviting you for a business deal where this money will be shared bet...
2013-01-22, 2099👍, 0💬

US phone number validation
How to perform a validation on US phone numbers using a regular expression? For example, "(021)423-2323" is an valid US phone number. To perform a validation on US phone numbers, try this regular expression: ^\(?\d{3}\)?[-\s.]?\d{3}[-\s.] \d{4}$
2013-01-27, 2093👍, 0💬

Negated white space character class - \S
What is abbreviation of a negated character class of all white space ASCII characters? Does it represents any characters except white space characters? How to write a regular expression using a character class abbreviation to capture tokens separated by white space characters in a text string like t...
2013-01-23, 2091👍, 0💬

Parsing all elements of URL addresses
How to parse out all elements from URL addresses with a regular expression? Here are URL address examples:ftp://ftp.example.org /https://login.example.com:5800 /?mode=guest&lang=enhttp://www.google.com:80/api/e xample/submit.php?name=joe#newfile://localhost/c|/WINDOWS/do cument.html#chapter1URL ...
2013-02-03, 2088👍, 0💬

Capturing query string from URL
How to capture query string from URL addresses with a regular expression? Here are URL address examples:ftp://ftp.example.org /https://login.example.com:5800 /?mode=guest&lang=enhttp://www.google.com:80/api/e xample/submit.php?name=joe#newfile://localhost/c|/WINDOWS/do cument.html#chapter1URL ad...
2013-02-03, 2080👍, 0💬

Parsing the "To:" field from emails
What would be the correct regex pattern to extract email addresses from a string coming from an email form "To" line, that allows the addresses to be delimited by commas ",", semicolons ";", or spaces? For example, the following "To" line contains 4 email addresses: "Joe Smith" , joe@aol.com; someon...
2013-01-30, 2077👍, 0💬

Using multiple lines and single line modifiers together - ms
What happens if I use multiple lines modifier, m, and single line modifier, s, together? How to write a regular expression to capture each bullet statement from this sample text:- The DAEMON or VENDOR label. - If the path is missing or incorrect, the product placed in the same directory as the x dae...
2013-02-02, 2066👍, 0💬

White space character class - \s
What is abbreviation of a character class of all white space ASCII characters? How to write a regular expression using a character class abbreviation to capture all white space characters in a text string like this: Name: Jack; Age: 25; City: Paris? The predefined abbreviation of a character class o...
2013-01-23, 2066👍, 0💬

Case insensitive modifier - i
What is case insensitive modifier? How to use it? How to write a regular expression to capture the "DIM" key word from this code example:Dim intArray(10, 10, 10) As Integer ReDim Preserve intArray(10, 10, 20) ReDIM Preserve intArray(10, 10, 15) Redim intArray(10, 10, 10) The regular expression to ca...
2013-02-03, 2065👍, 0💬

Negated decimal digit character class - \D
What is abbreviation of a negated character class of all decimal digits? Does it represents any characters except decimal digits? How to write a regular expression using a character class abbreviation to capture letters from a Canadian postal code string: L3R 9Z7? The predefined abbreviation of a ne...
2013-01-23, 2050👍, 0💬

Validating United Kingdom postcodes
How to write a regular expression to validate United Kingdom postcodes? For example, EC1A 1BB is a valid UK postcodes. Here is the regular expression to validate United Kingdom postcodes: [A-Z]{1,2}\d[A-Z\d]? \d[ABD-HJLNP-UW-Z]{2} [A-Z]{1,2} - 1 or 2 letters \d - A digit [A-Z\d]? - An optional lette...
2013-01-29, 2043👍, 0💬

Web address URL validation
How to perform a validation on Web address URLs using a regular expression? For example, "http://regex.fyicenter.com/" is a valid Web address URL. To perform a basic validation on Web address URLs, try this regular expression: ^https?:\/\/([A-Z0-9][-\w]*(\. [A-Z0-9][-\w]*)+):?(\d+)?\/?
2013-01-27, 2040👍, 0💬

Finding blank lines in a text file
How to find blank lines in a text file using regular expression? You can use the following logic to find blank lines in a text file: 1. Read each line from the text file in a loop. 2. Validate each line with this regular expression: ^\s*$ 3. If matched, you know that this line is a blank line.
2013-01-29, 2036👍, 0💬

n or more times repetition quantifier {n,}
What is the "n or more times" repetition quantifier? How to use it? How to write a regular expression using a repetition quantifier to capture the value of PI like: 3.1415926535897932384626433832 795028841971with a precision of at least 5 decimal digits? The "n or more times" repetition quantifier a...
2013-01-26, 2036👍, 0💬

US post code validation
How to perform a validation on US post codes using a regular expression? For example, "12345-5434" is an valid US post code. To perform a validation on US post codes, try this regular expression: ^([0-9]{5})(-[0-9]{4})?$
2013-01-27, 2032👍, 0💬

US Social Security Number validation
How to perform a validation on US Social Security Numbers using a regular expression? For example, "333-23-2329" is a valid US Social Security Number. To perform a basic validation on US Social Security Numbers, try this regular expression: ^[\d]{3}-[\d]{2}-[\d]{4}$
2013-01-27, 2030👍, 0💬

Capturing authenticated user name from Apache Web log file
How to capture the authenticated user name from Apache Web log file? Here are some Apache Web log file entries:127.0.0.1 - frank [10/May/2012:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326 "-" "-" "-" 213.135.131.79 - - [15/May/2012:19:21:49 -0400] "GET /features.htm HTTP/1.1" 200 9955 "http...
2013-02-03, 2010👍, 0💬

Finding content between two quotes
How to find content between two quotes in a text string using regular expression? For example, I have the following string: print "\$45.00\n"; Here is the regular expression to capture the content between two quotes: "([^"]*)"
2013-01-29, 2009👍, 0💬

<< < 1 2 3 4 5 6 > >>   Sort: Date