I have strings that look like this
{/CSDC} CHOC SHELL DIP COLOR {17}
I need to extract the value in the first swirly brackets. In the above example it would be
/CSDC
So far i have this code which is not working
Dim matchCode = Regex.Matches(txtItems.Text, "/\{(.+?)\}/")
Dim itemCode As String
If matchCode.Count > 0 Then
itemCode = matchCode(0).Value
End If
I think the main issue here is that you are confusing your regular expression syntax between different languages.
In languages like Javascript, Perl, Ruby and others, you create a regular expression object by using the
/regex/notation.In .NET, when you instantiate a
Regexobject, you pass it a string of the regular expression, which is delimited by quotes, not slashes. So it is of the form"regex".So try removing the leading and trailing
/from your string and see how you go.This may not be the whole problem, but it is at least part of it.