Reputation: 113946
I need to filter a set of strings with a wildcard-type search, like the following:
He*lo
should match "Hello", but not "Helo"*ant
should match "pant" and "want" but not "ant"*yp*
should match "gypsy" and "typical"The *
represents one or more characters. I don't mind a handwritten or regex-based search. Any ideas? The typical .NET approach for wildcards matches 0 or more, but I need 1 or more characters. How can I do this?
Upvotes: 5
Views: 18400
Reputation: 11763
You want the .
For example: he.lo
will match your hello
, but not helo
.
same goes for the rest.
You can easily test it here: http://regexpal.com/.
Do note that .yp.
will not match typical
nor gypsy
, but `.yp.+' will (because of the rest of the characters)
Upvotes: 1