The document provides 12 regular expressions for validating different types of integer numbers, including ranges for numbers, positive/negative integers, integers with thousands separators, hexadecimal numbers, and ZIP codes. It includes examples of strings that would match or not match each regular expression. The regular expressions can be used to validate number formats in applications. The document is intended to be a helpful reference for working with integer number validation through regular expressions.
2. Most Usefull Regex By Examples
1.
2.
3.
4.
5.
Regex Number with Range
Regex Allow Only Number
Regex Number Range
Regex Signed Integer
Regex Comma as the thousand separator and the dot as the
decimal separator
6. Regex Five Integer US ZIP Code
7. Regex Positive Integer
8. Regex non zero positive integer
9. Regex Integer with 1000s Separator
10. Regex Hexadecimal Numbers
11. Regex Hexadecimal Number with Range
12. Regex Binary Number
http://www.youtube.com/zarigatongy
3. • Five Integer US ZIP Code
^d{5}$
• Matches 33333 | 55555 | 23445
• Non-Matches abcd | 1324 | as;lkjdf
http://www.youtube.com/zarigatongy
8. Allow a string to only contain numbers 0 - 9 and
limit length to 50
^[0-9]{1,50}$
– Matches 00303039
– Non Matches 039330a29
http://www.youtube.com/zarigatongy
9. 1. Allow Only Number
– A[0-9]+Z
– ^[0-9]+$
http://www.youtube.com/zarigatongy
10. • Regex Number Range
a. 000..255: ^([01][0-9][0-9]|2[0-4][0-9]|25[0-5])$
b. 0 or 000..255: ^([01]?[0-9]?[0-9]|2[0-4][0-9]|25[05])$
c. 0 or 000..127: ^(0?[0-9]?[0-9]|1[01][0-9]|12[0-7])$
d. 0..999: ^([0-9]|[1-9][0-9]|[1-9][0-9][0-9])$
e. 000..999: ^[0-9]{3}$
f. 0 or 000..999: ^[0-9]{1,3}$
g. 1..999: ^([1-9]|[1-9][0-9]|[1-9][0-9][0-9])$
h. 001..999: ^(00[1-9]|0[1-9][0-9]|[1-9][0-9][0-9])$
i. 1 or 001..999: ^(0{0,2}[1-9]|0?[1-9][0-9]|[1-9][09][0-9])$
j. 0 or 00..59: ^[0-5]?[0-9]$
k. 0 or 000..366: ^(0?[0-9]?[0-9]|[1-2][0-9][0-9]|3[05][0-9]|36[0-6])$
http://www.youtube.com/zarigatongy
11. • Integer decimal number with an optional plus
or minus sign
[+-]?b[0-9]+b
http://www.youtube.com/zarigatongy
12. • comma as the thousand separator and the dot
as the decimal separator
^[0-9]{1,3}(,[0-9]{3})*.[0-9]+$
http://www.youtube.com/zarigatongy
13. • Hexadecimal Number With Range
• 0 to FFFF
^([1-9a-f][0-9a-f]{1,3}|[0-9a-f])$
• 1 to 366
^(16[0-9a-e]|1[0-5][0-9a-f]|[1-9a-f][0-9a-f]?)$
• 0 to 255
^[1-9a-f]?[0-9a-f]$
• ASCII codes
^(7[0-9a-e]|[2-6][0-9a-f])$
http://www.youtube.com/zarigatongy
14. More Protocol Tutorials
•
•
•
•
•
•
•
•
SSL Protocol Click here
DHCPv6 Protocol Click Here
CHAP Protocol Click Here
ISCSI Protocol Tutorial Click Here
BGP Tutorial Click Here
RADIUS Protocol Click Here
PPP Protocol Click Here
PPPoE Protocol Click Here
http://youtube.com/zarigatongy