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}
Related
This question already has an answer here:
Validating credit card format using regular expressions?
(1 answer)
Closed 3 years ago.
How to add a condition where if the first character is 4 then 16 digits and if 3 then 15 digits?
this is what i tried so far:
<ion-input
ngModel name="CNumber"
required
(ionChange)="C_number($event.target.value)"
(ionInput)="C_number($event.target.value)"
maxlength="{{Maxlength}}"
type="tel"
pattern="^(4)[0-9]{15}$"
>
^(4)[0-9]{15}
this will accept if the first is 4 and allows 16 characters, but how to add starting digit 3 and when so it accepts 15 characters only?
I'd try simple.alternative:
^((4)[0-9]{15})|((3)[0-9]{14})$
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
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:
How to validate phone numbers using regex
(43 answers)
Closed 7 years ago.
I need a regular expression for a phone number.
Example,
1234567899 should be (123)(456)(7899)
12345678 should be (123)(456)(78)
1234567 should be (123)(456)(7)
123456 should be (123)(456)
12345 should be (123)(45)
123 should be (123)
1 should be (1)
I tried /([0-9]{0,3})([0-9]{0,3})([0-9]{0,4})/ and /([0-9]{3})([0-9]{3})([0-9]{4})/
But it takes only when all the 10 numbers are in the input.
I need match then replace with (
This would appear to work:
/(\d{1,3})(\d{1,3})?(\d{1,4})?/
Live test here
Check this : /^\(\d{0,3}\)(\(\d{0,3}\))?(\(\d{0,4}\))?$/
https://regex101.com/r/qC0fS9/2
use this pattern
((^\d{1,3})|(?<=^\d{3})(\d{1,3})|(\d+$))
or simplified to
(^\d{3}|(?<=^\d{3})\d{3}|\d+$)
and replace with (\1)
Demo
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)