It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I need a regular expression which can detect 5 consecutive occurrences of any digit or character as given in below examples :
A11111C2 – INVALID
AAAAAAA21 – INVALID
12AXXXXX – INVALID
GGGG112 – VALID
You can match five consecutive characters with (.)\1\1\1\1. So .*(.)\1\1\1\1.* matches all your invalid cases.
The \1 is a backreference, so it only matches exactly what the first group (.) matched.
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
How would you construct a regex matching a password that must consist of 6 to 16 characters and contain at least one number or special character?
You need to define what constitutes special characters for you.
Something like this regex should work:
(?=^.*?[\d#;:'"()`~#!%$&=-])^.{6,16}$
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
For example the desired Regex would successfully match "areriroru" but wouldn't match "sadwdij" which contains just two of the vowels.
In C#, you can use lookahead assertions for each vowel before matching the string with .*:
(?=.*a)(?=.*e)(?=.*i)(?=.*o)(?=.*u).*
If you don't care about the case of your vowels, you could use this:
(?=.*[Aa])(?=.*[Ee])(?=.*[Ii])(?=.*[Oo])(?=.*[Uu]).*
One possibility is enumerating all the permutations of the vowels. Here are the first 24 of 120 total (all the ones where a is the first vowel). Note that this forms one long expression, but I split it into lines here for clarity.
a.*e.*i.*o.*u
|a.*e.*i.*u.*o
|a.*e.*o.*i.*u
|a.*e.*o.*u.*i
|a.*e.*u.*i.*o
|a.*e.*u.*o.*i
|a.*i.*e.*o.*u
|a.*i.*e.*u.*o
|a.*i.*o.*e.*u
|a.*i.*o.*u.*e
|a.*i.*u.*e.*o
|a.*i.*u.*o.*e
|a.*o.*e.*i.*u
|a.*o.*e.*u.*i
|a.*o.*i.*e.*u
|a.*o.*i.*u.*e
|a.*o.*u.*e.*i
|a.*o.*u.*i.*e
|a.*u.*e.*i.*o
|a.*u.*e.*o.*i
|a.*u.*i.*e.*o
|a.*u.*i.*o.*e
|a.*u.*o.*e.*i
|a.*u.*o.*i.*e
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I want a regular expression for using it in ASP.NET. It should be of 10 alphanumeric digits. The first 5 characters are letters, next 4 numerals and last character letter.
that should do the trick
^[a-zA-Z]{5}[0-9]{4}[a-zA-Z]$
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I need a regular expression for CLIA number. CLIA number is combination alpbh numeric without any spaces. Now i am using this expression /^[A-Za-z0-9]{10}$/ am i using correct expression?
you can use this....
/^[a-Z]{4}[0-9]{6}$/
^ this is used to beginning of the line.
$ end of the line.
a-Z this will match the both cases.
this case will match the four alpha character and six numbers. so totally 10 alphanumbers.
Based on your example, it sounds like you want the first four characters to be "CLia" followed by 6 digits? If so, use /^CLia\d{6}$/. If not, be more specific.
If your language support POSIX classes :
/^[[:alnum:]]{10}$/
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I need a regular expression for a password to fulfill the following requirements:
It must be at least 6 characters long
There must be 1 numeric character
The first and last character must be an alphabetic character
No special characters
I've found some expressions that come close to this, but none that match what I need.
Any help you can provide would be greatly appreciated.
I've tried this but it doesn't quite fit the bill:
^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).*$
Assert that a string has 6 or more characters:
(?=.{6,})
Assert that a string has at least 1 numeric character:
(?=.*\d)
Match an alphabetic character in the first and last position:
^[A-Za-z].*[A-Za-z]$
Combining all of the above, yields the following final expression:
(?=.{6,})(?=.*\d)[A-Za-z][A-Za-z0-9]*[A-Za-z]
try something like this
(?=.*\d)^[A-Za-z][0-9A-Za-z]{4,}[A-Za-z]$
or in the case that you want ONLY one numeric it would be this
(?=[^\d]*\d[^\d]*$)^[A-Za-z][0-9A-Za-z]{4,}[A-Za-z]$