Trying to parse an SQL string and pull out the parameters.
Ex: "select * from table where [Year] between @Yr1 and @Yr2"
I want to pull out "@Yr1" and "@Yr2"
I have tried many patterns, but none has worked, such as:
matches = Regex.Matches(sSQL, "\b@\w*\b")
and
matches = Regex.Matches(sSQL, "\b\@\w*\b")
Any help?
You're trying to put a word boundary after the @, rather than before. Maybe this:
\w(@[A-Z0-9a-z]+)
or
\w(@[^\s]+)