I would like to match strings with a wildcard (*), where the wildcard means "any". For example:
*X = string must end with X
X* = string must start with X
*X* = string must contain X
Also, some compound uses such as:
*X*YZ* = string contains X and contains YZ
X*YZ*P = string starts with X, contains YZ and ends with P.
Is there a simple algorithm to do this? I'm unsure about using regex (though it is a possibility).
To clarify, the users will type in the above to a filter box (as simple a filter as possible), I don't want them to have to write regular expressions themselves. So something I can easily transform from the above notation would be good.
YZ ABC X
match*X*YZ*
, i.e. do the substrings need to appear in the same order in both the string and the pattern or not? I'd assume it shouldn't match, but "string contains X and contains YZ" doesn't make it clear. If it should match, all the current answers are wrong. – Benedetto