求一段替换使用的正则表达式

[复制链接]
查看11 | 回复2 | 2021-1-27 06:31:07 | 显示全部楼层 |阅读模式
DimStr1asstring="select|update"
DimStr2asstring="select,update"
DimStr3asstring=Regex.Replace(Str2,str1,?,RegexOptions.IgnoreCase)

要求Str3的值是*elect,*pdate
?该怎么写才行?
或者说有没有这种可能?
分 -->
回复

使用道具 举报

千问 | 2021-1-27 06:31:07 | 显示全部楼层

stringcontent=@"select|update";
Regexreg=newRegex(@"([\S]+)\|([\S]+)");
Matchm=reg.Match(content);
content=reg.Replace(content,"*$1*$2");
MessageBox.Show(content);

回复

使用道具 举报

千问 | 2021-1-27 06:31:07 | 显示全部楼层
引用1楼的回复:C#code

stringcontent=@"select|update";
Regexreg=newRegex(@"([\S]+)\|([\S]+)");
Matchm=reg.Match(content);
content=reg.Replace(conte……

~~~
这个要怎样才能实用?
比如,我有个字符串"AAAAAAAAselectBBBBBBBBupdate"
把它替换成"AAAAAAAA*electBBBBBBBBBBBB*pdate"
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行