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})$
Related
This question already has answers here:
Using explicitly numbered repetition instead of question mark, star and plus
(4 answers)
Closed 4 months ago.
This should match
1233232985 John Doe
This should not match
John Doe 47437363
What I have attempted.
^\d{10-12}
Maybe this will help
"^[0-9]{10}$|^[0-9]{12}$"
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 an answer here:
How to use regex validator for phone numbers like 999-999-9999
(1 answer)
Closed 4 years ago.
I want to create a regex for this pattern 999-999-9999, please advise.
<input type='tel' pattern='/^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/' title='Phone Number (Format: 999-999-9999)' />
You nearly had it. Here's a simple one.
It goes: 3 digits, hyphen, 3 digits, hyphen, 4 digits. But that's pretty self explanatory.
\d{3}-\d{3}-\d{4}