I am converting VBA code that contains the LIKE operator, as in
dim sToken as String
if sToken Like "(*,*)" then ...
In all cases the patterns use only the * wildcard which matches any string (including the empty string). The VBA Like operator yields only a true/false result so it’s up to the subsequent VBA code to parse further and pluck out the matching substrings whenever there’s a match.
I’d be most appreciative if someone can provide a C# snippet to test for the same type of simple wildcard match. If the snippet also yields matching substrings – even better.
Well, that particular pattern could be matched with
but in general you may find it makes more sense to use regular expressions. For example:
Things to note with the pattern here:
The MSDN “Regular Expression Language Elements” page is a good reference for .NET regexes.