社区
C#
帖子详情
请教一个匹配替换的问题?
maotin
2003-07-30 04:27:22
"Left join Customer
On .....
Left join CustomerAddress
On ..... "
请问我如何替换成:
" Customer
On .....
Left join CustomerAddress
On ..... "
谢谢。
...全文
71
9
打赏
收藏
请教一个匹配替换的问题?
"Left join Customer On ..... Left join CustomerAddress On ..... " 请问我如何替换成: " Customer On ..... Left join CustomerAddress On ..... " 谢谢。
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
9 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
wzs_wzs123
2003-08-01
打赏
举报
回复
string strContent="Left join Customer On ..... Left join CustomerAddress On .....Left join Customer On ";
strContent=Regex.Replace(strContent,
@"\bleft\b\s+\bjoin\b\s+\bcustomer\b",
"Customer",RegexOptions.IgnoreCase);
MessageBox.Show(strContent);
liduke
2003-08-01
打赏
举报
回复
ArLi2003的办法我觉得最简单了
brightheroes
2003-07-31
打赏
举报
回复
我觉得还是用ArLi2003的办法吧
maotin
2003-07-31
打赏
举报
回复
主要是left join customer,我直接匹配是用这样:
text = text.Replace( "left join customer", ",customer" ),
但是把"left join customerAddress" 也替换了,
请教有么比较通用的替换法,
ArLi2003
2003-07-30
打赏
举报
回复
string s = "Left join Customer On ..... Left join CustomerAddress On ..... ";
if (s.ToLower().StartsWith("left")) s = s.Remove(0,9);
maotin
2003-07-30
打赏
举报
回复
这是我的做法,我觉得太复杂了,有没有更好的?谢谢
MatchCollection regexForConvert = Regex.Matches( oldText, @"\bleft\b\s+\bjoin\b\s+(?<name>\w+)", RegexOptions.IgnoreCase );
foreach( Match subString in regexForConvert )
{
String name = subString.Groups["name"].ToString().ToUpper();
int index = oldText.IndexOf( subString.Value.ToUpper() );
int keyLength = index + subString.Value.ToUpper().Length;
int textLength = oldText.Length - keyLength;
if( index > 0 )
newText += oldText.Substring(0, index);
newText += " " + name + ",";
newText += oldText.Substring(keyLength, textLength);
}
maotin
2003-07-30
打赏
举报
回复
是字符串
covis
2003-07-30
打赏
举报
回复
这是字符串还是什么?
maotin
2003-07-30
打赏
举报
回复
顶
请教
一个
正则表达式,
匹配
所有Html标签外部的指定字符串
请教
一个
正则表达式,
匹配
所有Html标签外部的指定字符串
正则
匹配
后面非指定字符的正则 原创
我想
匹配
后面只要不是x和.net的asp. 如:asp.net aspx asp aspyu 只需要
匹配
aspyu和asp这样的正则,我弄了老会,也没弄出来,大家帮忙啊 负向预查: [Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]这是我在经典论坛问的
一个
问题
,感谢Sheneyan(子虚乌有)版主 您可能感兴趣的文章:正则表达式
匹配
任意字符(包括换行符)的写法正则表达式
匹配
不包含某些字符串的技巧Java正则多字符串
匹配
替换
正则表达式
匹配
至少有
一个
非空白字符并且不超过指定长度
匹配
任意字符的正则表达式写法
请教
一个
正则表达式,
匹配
所
竞聘报告PPT模板.pptx
竞聘报告PPT模板.pptx
PJBlog3 bzbk.net模板
PJBlog3 bzbk.net模板
公开课语言表达之得体PPT课件.pptx
公开课语言表达之得体PPT课件.pptx
C#
111,119
社区成员
642,538
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章