关于正则表达式!请帮帮我吧!!!!

hoours 2004-08-27 10:46:02
誰能帮我写个把这个字符串
“select id,title,author from eeggs where id=1 and author='HouRS' order by ID DESC”
分解成
GROUP1=“select id,title,author”
GROUP2=“from eeggs”
GROUP3=“where id=1 and author='HouRS'”
GROUP4=“order by ID DESC”
的正则表达式!!!

先谢了!!
...全文
268 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
robin_xin_xin 2004-12-31
  • 打赏
  • 举报
回复
string strReg=@"(select.*?)(from.*?)(where.*?)(order by .*?$)"
string strResource="select id,title,author from eeggs where id=1 and author='HouRS' order by ID DESC";
MatchCollection _mc;
RegexOptions _regoption=RegexOptions.Multiline;
_mc=Regex.Matches(strResource,strReg,_regoption);

Match _current=_mc[0];
str GROUP1=_current.Group[1].Value;
str GROUP2=_current.Group[2].Value;
str GROUP3=_current.Group[3].Value;
str GROUP4=_current.Group[4].Value;

hfcc999 2004-12-21
  • 打赏
  • 举报
回复
^(?<group1>select.+(?=from))(?<group2>from.+(?=where))(?<group3>where.+(?=order by))(?<group4>order.*)$

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧