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.
Please can you help me, I need a regex expressions to only allow whole numbers and the string cannot be blank.
Thanks
/^-?\d+$/
This regex would match one or more digits. So won't allow blank as required, and would only allow whole numbers
Actually the + after \d imposes that at least one digit be present in the input string.
The - in the beginning checks for a -, and the following ? makes it optional.
You should try this one:
^\d+$
^ : begining of the string to capture
$ : end of the string to capture
\d : all the digits (equivalent to [0-9])
+ : at least one of the class
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.
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 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]$
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.
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 11 years ago.
How can I allow a dot in an URL using Regex? Any advice?
thanks
\. will allow you to match a dot. How you insert that into your regex depends on how you've created your regex.
. in a regex allows any character (except newlines, depending on the engine and its options), so you have to escape it as \.
Since you're being vague, so will I:
\.
There's the regex to allow a dot.
use the \ to escape native match chrs