I have a list of wild card based patter in a XML file. If the input string matches the pattern present in the XML doc, then a specific action would be taken.
I did find the approach mentioned here http://www.codeproject.com/KB/recipes/wildcardtoregex.aspx but in that case, I need to create a RegEx object for every entry in the XML which I am trying to avoid.
Let me know is there any better way to do wild card search in .net
If you wish to evaluate each pattern in you document to match against the input string, you’ll have to create a RegEx for each pattern, like you mention. There’s no shortcut.
I guess you worry about perfomance. Are you sure it’s a problem? If so, you should try to find a different approach altogether.
Are you going to match many input strings? In that case, you should keep your RegExes (in a list, say) rather than creating them each time. RegExes can be reused.
Otherwise, I can see no big problem with your proposed approach.