By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,035 Members | 1,471 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,035 IT Pros & Developers. It's quick & easy.

Regex Validation

P: 10

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?
Jan 26 '09 #1
Share this Question
Share on Google+
2 Replies

P: 1
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.

Expand|Select|Wrap|Line Numbers
  1. static bool IsEquivalentString(string s1, string s2)
  2.   return s1==Regex.Replace(s2,"[^a-zA-Z]","");
  3. }
Hope this helps

Jan 26 '09 #2

P: 10
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.
Jan 26 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.