Quantcast
Channel: Need to perform Wildcard (*,?, etc) search on a string using Regex - Stack Overflow
Viewing all articles
Browse latest Browse all 12

Need to perform Wildcard (*,?, etc) search on a string using Regex

$
0
0

I need to perform Wildcard (*, ?, etc.) search on a string.This is what I have done:

string input = "Message";string pattern = "d*";Regex regex = new Regex(pattern, RegexOptions.IgnoreCase);if (regex.IsMatch(input)){    MessageBox.Show("Found");}else{    MessageBox.Show("Not Found");}

With the above code "Found" block is hitting but actually it should not!

If my pattern is "e*" then only "Found" should hit.

My understanding or requirement is d* search should find the text containing "d" followed by any characters.

Should I change my pattern as "d.*" and "e.*"? Is there any support in .NET for Wild Card which internally does it while using Regex class?


Viewing all articles
Browse latest Browse all 12

Latest Images

Trending Articles





Latest Images