Reputation: 135
I'm looking for a Regex(C#) to match the words "ass" or "a**". That is if the input text contains the word "ass" or "a**" the regex should match. Kindly help me with this.
Thanks in advance.
Upvotes: 0
Views: 1820
Reputation: 336078
Regex.Match(@"\ba(?:ss\b|\*\*)", RegexOptions.IgnoreCase)
The \b
word boundary anchors ensure that you won't accidentally match on assorted
or bass
.
Upvotes: 7