Regex Validation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • varunrap
    New Member
    • Jul 2008
    • 10

    Regex Validation

    Hi,

    I have an application in which I need to validate a word which might have multiple variation. For example, the word "trust". I need a regex validation to pull out variations like, trusty, tr-ust, tr ust, trustall. Could anyone suggest a regex pattern for this?
  • vj01
    New Member
    • Jan 2009
    • 1

    #2
    You cannot really use regex to validate against possibly hundreds of related words related to one word (you can also have trustee, trustiness, trustworthy, trustful, etc.)

    Regex validation will however allow you to strip any non-alpha characters, so you can compare only the alpha characters of the word.

    Therefore tr-ust, tr'ust, tr ust or t*r*u*s*t will always validate to trust.

    Code:
    static bool IsEquivalentString(string s1, string s2)
    { 
      return s1==Regex.Replace(s2,"[^a-zA-Z]","");
    }
    Hope this helps

    Vijay

    Comment

    • varunrap
      New Member
      • Jul 2008
      • 10

      #3
      Stripping out alphanumeric characters, is not an option. Unfortunately due to the configuration and setup of the application, I need something that will block the different varitions of the word.

      Comment

      Working...