• 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.
  • 2
1 Solution
David S.Commented:
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")
Peter KwanCommented:
If the above comment is ok for you, then the regular expression to test whether a string ends with "es" is:

ASINGH1974Author Commented:
Actually I am using a dynamic pattern check for matching the string.

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.

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