This question already has answers here:
numbers not allowed (0-9) - Regex Expression in javascript
(6 answers)
Closed 2 years ago.
I am trying to create a react(javascript) form, In that one field should allow all values (Uppercase letters, Lowercase letters and special characters) but not numbers.
Is there any regex or any other solution?
Thanks in advance.
You can simply check that a string DOESN'T contain numbers using regex \d which matches all numbers:
!(/\d/.test(string))
Related
This question already has answers here:
How to match all numerical characters and some single characters using regex
(3 answers)
Closed 2 years ago.
I have an essay as a big string with letters and numbers (as page numbers) (only single digit and double digits). I want all of them to be replaced by "#". I tried str.replace(/[0-9]/g,"#"), this worked for 0 to 9 numbers, but with the double digits, they were replaced by "##", so how can I replace them all with a single "#"?
If you want to replace only 1 or 2 digits in a line:
str.replace(/[0-9]{1,2}/, "#")
If you want to replace all digits in a line:
str.replace(/[0-9]+/g, "#")
This question already has answers here:
REGEX - Allow Numbers and . - /
(7 answers)
Closed 2 years ago.
Currently I have a textbox that accepts only Alphabet, hyphens(-), space and apostrophes('). Now I would like to add numeric values as well to it. Currently I am using the Regex as below:
/^[a-zA-ZÀ-ÖØ-öø-ÿ' -]+$/
How would I achieve adding numerics as well to the above?
To allow numbers, simply add 0-9 in your regex, like so:
/^[0-9a-zA-ZÀ-ÖØ-öø-ÿ' -]+$/
This question already has answers here:
Regex to validate password strength
(11 answers)
Closed 4 years ago.
What can be a valid regex for a password that contains at least 8 characters in which there should be one upper-case,one lower-case and one number?
Here is a regular expression for a string with at least 8 characters, one upper-case, one lower-case and one number.
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$
This question already has answers here:
JavaScript regex for alphanumeric string with length of 3-5 chars
(3 answers)
Closed 7 years ago.
I need REGEXP for alpha Numeric zip code, which contains minimum 3 & maximum 10 values.
Invalid inputs are: AAAAA, A1, AA, 12, 2A
Valid inputs are: 123456, 123, A1234, A12, A12A, A9A
This is the regex I'm currently using:
/(^[A-z0-9]\d{3,10})+$/
It doesn't allow to specify only digits like this 12345 but input like A123 matches correctly.
The question is not completely clear. If you mean that you can use between 3 and 10 characters, and these characters can be alphanumerical characters (digits and [A-Za-z]), you can use:
/^(?=.*\d.*)[A-Za-z0-9]{3,10}$/
regex101 demo.
The regex works as follows:
^[A-Za-z0-9]{3,10}$ says the regex consists out of 3 to 10 characters that can be digits and/or A-Z/a-z.
The lookahead (?=.*\d.*) enfoces that the string contains at least one digit somewhere in the string.
This question already has answers here:
I want to ignore square brackets when using javascript regex [duplicate]
(4 answers)
Closed 8 years ago.
I have a very simple form with this regex pattern set on my first/last name fields ng-pattern="/^[a-zA-z]{2,30}$/" and both fields accept this value as being valid e.g. Tester\^*&^%. The first/last name should only accept alpha character a-zA-Z with a minimum of 2 characters and a max of 30.
Here is the wrong thing.
^[a-zA-z]{2,30}$
^
|
It would match \^ symbols because these symbols are comes under the range from A to z.
Modified regex.
^[a-zA-Z]{2,30}$