如果用正则表达则怎么写呀??

feifeiyaqi3 2009-05-07 02:21:00
1. ResultInfo result = entity.GetModel("UI_Name='" + this.TextBox2.Text.Replace(" ", "").Replace(" --", "").Replace("'", "") + "' and UI_PassWord='" + this.TextBox1.Text.Replace(" ", "").Replace(" --", "").Replace("'", "") + "'");

2. 上面的REPLACE()中过滤的功能为
Replace(" ", "") 过滤 空格
.Replace(" --", "")过滤 --
.Replace("'", "") 过滤 ‘
这样理解对吧。

3. 如果用正则表达则怎么写呀??

谢谢





...全文
60 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangjianchao 2009-05-07
  • 打赏
  • 举报
回复
C# codeResultInfo result = entity.GetModel("UI_Name='" + Regex.Replace(this.TextBox2.Text, @"[\s']|--", "") + "' and UI_PassWord='" + Regex.Replace(this.TextBox1.Text, @"[\s']|--", "") + "'");

c#里内有现成的方法只需调用就行了,正则表达式的写法和其他地方的用法 一样,上楼的写法就行

-过客- 2009-05-07
  • 打赏
  • 举报
回复
try...

ResultInfo result = entity.GetModel("UI_Name='" + Regex.Replace(this.TextBox2.Text, @"[\s']|--", "") + "' and UI_PassWord='" + Regex.Replace(this.TextBox1.Text, @"[\s']|--", "") + "'"); 

111,126

社区成员

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

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

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