Ahmed ilyas Ahmed ilyas - 6 months ago 4
Vb.net Question

Regex from VB to C# (LIKE to Regex)

So, VB6/VB.NET has a

keyword, which is kind of like a Regex.

I know what this is doing but I am not an expert in Regex and was hoping someone could kindly help (AND I want to use Regex and not string specific stuff like IndexOf/get the last char):

VB code:

If (someDataStr Like "[*]??????????????8") Then
end if

So I am focusing on this:


what would this be in terms of a Regex expression?


Based on Damien_The_Unbeliever's link, I assume that your pattern matches a literal *, 14 arbitrary characters and then a literal 8.

Then this would be your regex:


Note that . will not generally match line breaks. If you need it to, then set the SingleLline option.

Match match = Regex.Match(input, @"^\*.{14}8$", RegexOptions.Singleline)

if (match.Success)
    // string has valid format