tags:

views:

154

answers:

1

Using regular expressions in .NET with the pattern ^%[^%]+%\Z and the string "few)few%" I get the error - System.ArgumentException: parsing "few)few%" - Too many )'s.

Dim match As System.Text.RegularExpressions.Match = System.Text.RegularExpressions.Regex.Match("^%[^%]+%\Z", "few)few%")

What would the issue be? Do I need to escape brackets in any input expression to reg ex?

(I'm trying the determine if string has the wildcard % at the beginning and end of the string but not elsewhere in the string)

+5  A: 

No, your input does not have to be escaped. You simply have your arguments the wrong way around.

From MSDN:

public static Match Match(
    string input,
    string pattern
)
Aistina
I had been doing it the right way around all day long too, there's something about friday evenings that makes you unable to see simple coding mistakes. Thanks for pointing that out.
Chris Herring