Regex "NOT" exists Pattern [closed] - c#

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$).*$

Related

Regex for Name text box in registration form [closed]

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

Single digit followed by two alphabets regex [closed]

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

Can someone explain this Regex to me [closed]

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 found this regex in working C# code. Can someone explain it to me please :
#"(?s)\{\{\s*" + templateTitle + #"(.*?)}}\r?\n?"
I tested it and it returns text like
{{ templateTitleValue anything}}
What I don't understand is the two '}}' that are not escaped by \ like the two '}}'. And what is '(?s)' in the beginning.
Thanks
Actually, you don't need to escape the opening braces either. It's clear from context that they are not quantifiers (as in X{1,3} which would match X, XX or XXX). But it's good practice to escape them anyway (and to also escape the closing ones), just in case the regex changes into something where there could be some ambiguity.
(?s) means "allow the dot (.) to match all characters, including newlines". This is also known as the Singleline or DOTALL option.

.NET: "identity\\..*" does not match "identity.requesttoken" [closed]

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\..*")

Custom regular expression [closed]

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
Hi I need to match this format
N - Number
NN,NN
or
NN.NN
also
N,N and N.N
and combinations
N.NN and N,NN or NN,N and NN.N
Here's your regex:
\d{1,2}[.,]\d{1,2}
See it here in action: http://regexr.com?2vman
Here's a slightly different version:
\d\d?[.,]\d\d?
See it here in action: http://regexr.com?2vmaq
If you want to also match with out a decimal, use this:
\d\d?[.,]?\d{0,2}
See it here in action: http://regexr.com?2vml4
How about:
\d{1,2}(?:[.,]\d{1,2})?
explanation:
\d{1,2} : one or two digits
(?: : start non capture group
[.,] : . or ,
\d{1,2} : one or two digits
)? : end group, optional
Why match it?
Just remove the commas and use the actual number:
Regex.Replace("8,675,309.02", "(,)", string.Empty) // Outputs 8675309.02
If this is a validation scenario, using int.Parse will let you know if its valid.
I would go with something like this:
Regex regex = new Regex(#"\d{1,2}[\.,]\d{1,2}");

Categories

Resources