This question already has answers here:
Using regular expressions to validate a numeric range
(11 answers)
Closed 3 years ago.
How to put a number greater than 9 to regexp character set?
For example, I can do ^[01236]$, but what if I want to put 100 as an option to the set?
How do I solve this problem?
'\d+' can find number having 1 or more digits
If a number is greater than 9, it is more than 2 digits and the first digit is not 0. So the regex you might want to use is: ^[1-9][0-9]+$
If you want to put a specific multi character strings you can use:
^(10|100|200|301|601)$
Which will match 10, 100, 200, 301, and 601
test: https://regex101.com/r/bptbsx/1
Related
This question already has an answer here:
Reference - What does this regex mean?
(1 answer)
Closed 2 years ago.
What will be the regular expression to find a numerical string starting with a number other than 0 and having a length of 13 or more. This numerical string would be a substring inside a bigger alphanumeric string.
/[1-9][0-9]{12,}/
You're looking for a number from 1 to 9, then for 12 or more numbers from 0 to 9.
This question already has answers here:
How to validate phone numbers using regex
(43 answers)
Closed 2 years ago.
I have a TextFormField for a phone number and I want to validate the input to match my RegEx to phone number value
the valid inputs are
075xxxxxxxx
077xxxxxxxx
078xxxxxxxx
079xxxxxxxx
I tried this r"^ (?:[0]7)?[0-9]{11}$" but its not working
any way to do it right?
Match a zero, then a 7, then any of [5,7,8,9] then any 8 digits:
07[5789]\d{8}
This question already has answers here:
Regex for Australian phone number validation
(5 answers)
Closed 4 years ago.
The below expression is being used to accept Australian phone numbers.
I need to change the expression as to strictly accept total 10 digits (without spaces) if the number starts with 02/03/04/07/08.
^\({0,1}((0|\+61)\s?(2|4|3|7|8)){0,1}\){0,1}(\ |-){0,1}[0-9]{2}(\ |-){0,1}[0-9]{2}(\ |-){0,1}[0-9]{1}(\ |-){0,1}[0-9]{3}$
It does accept 10 digits if the number is entered like 03 11 11 1 111, but without spaces 8 digit number is accepted too.
You can use the use the following regex with alternation:
^ *(?:0 *[23478](?: *\d){8}|[1-9](?: *\d)*|0 *[01569](?: *\d)*) *$
Demo: https://regex101.com/r/bet7m1/1
This question already has answers here:
Using regular expressions to validate a numeric range
(11 answers)
Closed 4 years ago.
How to write regular expression which accept numbers between 1 to 25000>
I tried like this ^([1-2]?[1-4]?[0-9]{0,3}|25000)$
Here's a regex that will only accept a string with a number between 1 and 25000.
Without proceeding zero's.
^([1-9]\d{0,3}|1\d{4}|2[0-4]\d{3}|25000)$
It basically separates it in 4 ranges
[1-9]\d{0,3} : 1 to 9999
1\d{4} : 10000 to 19999
2[0-4]\d{3} : 20000 to 24999
25000 : 25000
A regex101 test can be found here
To find those numbers as a part of a string, you could replace the start ^ and end $ by a wordboundary \b.
Btw, in most programming languages it's often simpler to just check if it's a number that's in the accepted range. Even in HTML there's an input type for numbers where you can set the minimum and maximum.
Try
^(?!0$)((1\d|2[0-4]|\d)?\d{1,3}|25000)$
First negative lookahead will reject a value of only 0.
The group (1\d|2[1-4]|\d)? means that a 5-digit number with an initial digit of 2 requires it to be followed by a 0-4.
https://regex101.com/r/1DgbBM/4
This question already has answers here:
Regex to match only letters
(20 answers)
Closed 9 years ago.
I was looking for a regex that can validate phone numbers, but somehow i cannot find a universal solution.
So i just want to check if the string has any alphabets that is a-z
If it does not then pass it, for example
000 -> Pass
000(1) -> Pass
000a -> Fail
(?mx)^(?=.*?([0-9]))((?![a-zA-Z]).)*$
This will check to see if your line has any numbers in it while NOT having any alpha chars. See the example here.
its for phone numbers validation
RegExp(/^[0-9 +()-]{3,30}$/i)
for only string
RegExp(/^[a-zA-Z]{1,2}$/i)