rutledgj
asked on
vb.net Need regex to find suffix in name
Could someone show me how to use regular expression to look for common suffixes in a person's name?
ASKER
Fine, Then how do you call the expression to return a true/false condition?
Be sure to turn on case-insensitivity. I forgot to demonstrate that above.
Regex.IsMatch(input, pattern, RegexOptions.IgnoreCase)
You can use the method I demonstrated immediately above for a true/false return.
ASKER
Is it possible to use the expression to just remove it from the name to begin with?
MyName.Replace(pattern,"") ?
MyName.Replace(pattern,"")
Certainly:
Regex.Replace(input, pattern, String.Empty, RegexOptions.IgnoreCase)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok. Thanks. Big help.
Open in new window
You can add more suffixes by inserting a pipe ( | ) and then the suffix. Make sure you escape any dots with a backslash like I did above.