【发布时间】:2016-04-29 00:56:35
【问题描述】:
我有像
这样的 sql 字符串select * from dbo.Person where Person = ? AND Name = ? OR (Country = ? OR City = 1)
如果可以在 C# 中使用 Regex 获得如下字符串数组
result[0] = Person = ?
result[1] = Name = ?
result[2] = (Country = ? OR City = 1)
谢谢。
【问题讨论】:
-
真的要自己解析sql吗?如果有,为什么?
-
from dbo.Person where Person的意思是人是表名还是列名? -
这对于现实世界的应用程序是必要的吗?如果是这样,以我的拙见,它不应该..
-
是的,因此您可以制作正则表达式并为此使用 Regex.Matches(string, regex) 。