regex for numbers

Solutions on MaxInterview for regex for numbers by the best coders in the world

showing results for - "regex for numbers"
Mario
09 Jan 2020
1' Needs reference "Microsoft VBScript Regular Expressions 5.5"
2Dim rRegex As Object
3Set rRegex = CreateObject("VBScript.RegExp")
4
5rRegex.Pattern = "[0-9]{8,9}"   ' 8 or 9 numbers
6MsgBox rRegex.test("12345678")  ' True
7
8rRegex.Pattern = "[0-9]+"       ' Numeric of any size
9MsgBox rRegex.test("12345")     ' True
Carla
14 Aug 2018
1For matching an integer number of one single char/digit, specify:
2[0-9]
3But for matching any number of more than one char/digit; add "+":
4[0-9]+
5Example for matching hour with minutes of HH:MM format in a file:
6grep "[0-9]\+\:[0-9]\+" file.txt
Jacopo
18 May 2018
1Regex regex = new Regex(@"^\d$");
2
similar questions
queries leading to this page
regex for numbers