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

Answer by Adam Szabo for Need to perform Wildcard (*,?, etc) search on a string using Regex

$
0
0

You can do a simple wildcard mach without RegEx using a Visual Basic function called LikeString.

using Microsoft.VisualBasic;using Microsoft.VisualBasic.CompilerServices;if (Operators.LikeString("This is just a test", "*just*", CompareMethod.Text)){  Console.WriteLine("This matched!");}

If you use CompareMethod.Text it will compare case-insensitive. For case-sensitive comparison, you can use CompareMethod.Binary.

More info here: http://www.henrikbrinch.dk/Blog/2012/02/14/Wildcard-matching-in-C

MSDN: http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.compilerservices.operators.likestring%28v=vs.100%29.ASPX


Viewing all articles
Browse latest Browse all 12

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>