Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am new to regular expression. I need a regular expression to validate single digit within range of [1-5] followed by alphabet [A-C] and followed by optional alphabet [X-Z]
1A (Valid)
2BZ (Valid)
7B (Invalid)
What you tried is right, except you're missing the start and end characters, so it's succeeding on a partial match.
You need:
^[1-5][a-cA-C][x-zX-Z]?$
Use online testers to validate it:
[1-5]+[A-C]+[X-Z]*
regexpal
gskinner
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Which allows Single Space between two words like "Naresh Kumar" Doesn't allow Special Characters and Number.
Doesn't allow empty Field and Space at Start of string
Use this regex:
Regex.Match(name, #"^[a-zA-Z]+\s[a-zA-Z]+$");
[a-zA-Z]+ : means any letter one or more times.
\s : single space
^ : beginning
$ : end
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm kinda rusty with regular expressions. I need a REGEX that will validate values formatted like the following:
123.00
123,00
1324,00
1234.00
123
1213.0
I tried ^\d.\d{2}$, but it does not seem to match all values.
Appreciate any assistance.
You can use the following:
\d+[.,]?\d+
Good luck!
\d+[,.]?\d*
I would strongly advise against mixing cultures especially for persistence or transport.
The Regex you're likely looking for is something like #"\d+([,.]\d+)?"
It specifies "Some number of digits, optionally followed by a . or , and at least one digit". It would not match 123..
If you want to match culture-specific strings, however, I'd recommend using NumberFormatInfo.CurrencyDecimalSeparator and then look for that specifically.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a regular expression which matches words which do NOT start with "DEF".
Now I would like to modify it to following three cases:
Does NOT END with "DEF"
Does NOT Contains "DEF"
Does NOT Equal TO "DEF"
what should I modify the string patterns ?
Regex pattern Match word which does NOT start with word "DEF": ^(?!DEF).*$
match word : ADEFCCC
Does Not Match : DEFXXX
Does not end with DEF: ^.*(?<!DEF)$
Does not contain DEF: ^((?!DEF).)*$
Does not equal DEF: ^(?!DEF$).*$
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have this Pattern it's worked successful:
#"^-?(0\.\d*[0-9]|[0-9]\d*(\.\d+)?)$
but I want this pattern not allow zero like this inputs:
not allowed inputs:
0.0 //not allowed
00.00 //not allowed
allowed inputs:
0.07 // allowed
0.70 // allowed
and any number decimal
I would use a negative lookahead assertion to make the regex fail if it is only "0".
#"^-?(?!0*(\.0*)?$)(0\.\d*[0-9]|[0-9]\d*(\.\d+)?)$
See it here on Regexr
This expression (?!0*(\.0*)?$) makes the whole regex fail, if the number consists only of zeros.
Regular expressions are for matching patterns, not checking numeric values. Find a likely string with the regex, then check its numeric value in whatever your host language is (PHP, whatever).
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm trying to match a string in .NET Regex, I want the expression to match "identity." with anything added to the end (can still limit the scope of * later on), testing the pattern in any regexeditor works just fine (I have one less backslash there, due to escaping).
I have set a breakpointright on my Regex.IsMatchto check the values, there are exactly what I put in the title (note that this is from the VS2010 debugger, escape sequences are unparsed)
Try using a string literal (prefix the string with #) when specifying your regex. This will remove the need for you to escape the \:
Regex.IsMatch("identity.requesttoken", #"identity\..*")