x Did you like it? Well, then please consider making a donation :)

Regex Tag - parsing

Validate numbers

If Possible, Don't Use Regex To Validate Numbers. If at all possible, use your language. There may be functions to help you determine if the value contained by a string is a valid number. That being said, if you're accepting a variety of formats (commas, etc.) you may not have a choice.

Type: match, Date: 7/12/2015 4:07:04 PMAuthor: stackoverflow

Get only Arabic digits

Use ([0-9]+) if you need to match more than one digit (only Arabic numbers!). Use (\d+) if you need all digits (all unicode digits).

Type: match, Date: 7/12/2015 4:00:33 PMAuthor: stackoverflow

Regex - \d is less efficient than [0-9] - get ALL Unicode digits

\d checks all Unicode digits, while [0-9] is limited to these 10 characters. For example, Persian digits, ?????????, are an example of Unicode digits which are matched with \d, but not [0-9]. [0-9] isn't equivalent to \d. [0-9] matches only 0123456789 characters, while \d matches [0-9] and other digit characters, for example Eastern Arabic numerals ٠١٢٣٤٥٦٧٨٩

Type: match, Date: 7/12/2015 2:34:00 PMAuthor: stackoverflow

Regular expression to extract the year (1900 - 2099) from a string

Getting year from text. If you want validate textbox value - use this pattern with "^" and "$": ^((19|20)\d{2})$

Type: match, Date: 3/28/2015 4:38:20 PMAuthor: admin

Get all HTML tags from page

Using a RegularExpression to match web (HTML code).

Type: match, Date: 3/27/2015 4:21:44 PMAuthor: admin