正则表达式提取以@开头的单词
尝试解析 SQL 字符串并提取参数。
例如:“从表中选择*,其中@Yr1和@Yr2之间的[年份]”
我想取出“@Yr1”和“@Yr2”
我尝试了很多模式,但没有一个有效,例如:
matches = Regex.Matches(sSQL, "\b@\w*\b")
和
matches = Regex.Matches(sSQL, "\b\@\w*\b")
有什么帮助吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您试图在 @ 之后而不是之前放置单词边界。也许这个:
或
You're trying to put a word boundary after the @, rather than before. Maybe this:
or
我会选择
or 如果你不想包含@,
尽管我也喜欢上面的 joel,所以也许是其中之一
I would have gone with
or if you didn't want to include the @
though I also like joel's above, so maybe one of these