• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 939
  • Last Modified:

Match a string pattern in Regular expression that does not contain a particular string.

Hi everyone,

I m searching solution to the problem

I have to match only those strings that don't end with "es" and "ies" using Regex.

plz give me a solution ASAP.

thanx in advance.
0
ASINGH1974
Asked:
ASINGH1974
  • 2
1 Solution
 
David S.Commented:
0
 
Peter KwanCommented:
Can you do the negation in your programming language? What I mean is you test your search string and find if the string ends with "es" (actually "ies" is a case of "es"), then negate the result (i.e. return true only if the string does not end with "es"/"ies")
0
 
Peter KwanCommented:
If the above comment is ok for you, then the regular expression to test whether a string ends with "es" is:

.+es$
0
 
ASINGH1974Author Commented:
Actually I am using a dynamic pattern check for matching the string.
i.e.

foreach(string patternString in db.getRegexPatterns())
{
      if(Regex.IsMatch(inputString, patternString))
       { //-------}
}

different inputs will match with different patterns.
I want that "www.google.com" or "www.rediff.com" will match but
"www.google.map.com" and "www.rediffmail.com" will not be a valid input.

also, I cant use it at the code side in my program, I hav to use it only in patternString which is stored in database.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now