Replace multiple spaces exampleType: replace, Date: 7/12/2015 4:10:18 PMAuthor: stackoverflow
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
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
You can use capturing groups to organize and parse an expression. A non-capturing group has the first benefit, but doesn't have the overhead of the second. You can still say a non-capturing group is optional, for example.
Say you want to match numeric text, but some numbers could be written as 1st, 2nd, 3rd, 4th... If you want to capture the numeric part, but not the (optional) suffix you can use a non-capturing group.
That will match numbers in the form 1, 2, 3... or in the form 1st, 2nd, 3rd,... but it will only capture the numeric part.Type: match, Date: 7/12/2015 3:26:19 PMAuthor: stackoverflow