原字段内容中包括以下URL(也有可能一字中包括多个类似的URL):http://pic.jinti.com/member/7326419/20096810374579.jpg
(sql查询符合的条件:select context from list where context like '%http://pic.jinti.com/member/%')更新成:http://pic3.jinti.com/album/20090608/20096810374579.jpg
注:http://pic3.jinti.com/album/和http://pic.jinti.com/member/是固定的
(sql查询符合的条件:select context from list where context like '%http://pic.jinti.com/member/%')更新成:http://pic3.jinti.com/album/20090608/20096810374579.jpg
注:http://pic3.jinti.com/album/和http://pic.jinti.com/member/是固定的
解决方案 »
- C# Devexpress 的TreeList 的RefreshDataSource( ) 方法无效
- 大神求助
- 若要在加载设计器前避免可能发生的数据丢失,必须纠正以下错误
- c#用webbrowser来伪造网站来路如何实现
- 在窗口中单击浏览按钮,选择一个XML文件,在tree中显示XML随对应的树形结构。
- 谁知道“TCP-IP详解,FTP协议规范"的作者、出版社、出版时间啊?毕业设计里的参考文献用
- 请教:如何利用DataAdapter保存多条添加的记录
- 程序不能持续运行
- WCF服务与THREAD.TIMEr问题
- 关于两个DataTable获取差异和共同部分
- 快来看啊!!!!!!!!!!!!!!这是什么???/
- 有关SQL的update
update list set context=replace(context,'http://pic.jinti.com/member/','http://pic3.jinti.com/album/') where context like '%http://pic.jinti.com/member/%'
7326419/20096810374579.jpg
更换成20090608/20096810374579.jpg
7326419/20096810374579.jpg
更换成20090608/20096810374579.jpg 7326419是用户ID,更新成20096810374579.jpg文件名的前面的年月日20090608
string url=@"http://pic.jinti.com/member/7326419/20096810374579.jpg ";
url.Replace(@"http://pic.jinti.com/member/",@"http://pic3.jinti.com/album/");
//方法原形:String.Replace (OldString, NewString); 用NewString 代替string中所有的 OldString 注:如果string中有多个类似的地址也可以用这种方法解决!
set context=
replace(context,'http://pic.jinti.com/member/7326419',
'http://pic3.jinti.com/album/20090608')
where context like '%http://pic.jinti.com/member/%'
String str=@"http://pic.jinti.com/member/7326419/20096810374579.jpg";
Regex objRegex = new Regex(@"(?i)(?<=\/)(\d+)\/(\d{8})(?=\d+\.jpg$)");
String strReturn = objRegex.Replace(str, "$2/$2");
或用函数charindex取值/20096810374579.jpg ,再取年月
http://pic.jinti.com/member/%'id context
1 我是中佃人http://pic.jinti.com/member/7326419/20096810374579.jpg中国
2 粗体http://pic.jinti.com/member/73/20096810374579.jpg是吗?http://pic.jinti.com/member/342342/200941210374579.jpg测试要求更新成:
id context
1 我是中佃人http://pic.jinti.com/album/20090608/20096810374579.jpg中国
2 粗体http://pic.jinti.com/album/20090610/20096810374579.jpg是吗?http://pic.jinti.com/album/20090412/200941210374579.jpg测试注:http://pic3.jinti.com/album/和http://pic.jinti.com/member/是固定的
需要将7326419/20096810374579.jpg
更换成20090608/20096810374579.jpg
7326419是用户ID,更新成20096810374579.jpg文件名的前面的年月日20090608
它标示的是2009年12月12日?还是2009年1月2日?还是2009年12月1日?还是2009年1月21日?
功能基本实现,以下举个例子供参考,谢谢
string temp = "xxxxxxxxhttp://pic.jinti.com/member/7326419/20096810374579.jpg";
string Result=temp.Replace(temp.Substring(temp.LastIndexOf("xxxxxxxxhttp://pic.jinti.com/member/") + "http://pic.jinti.com/member/".Length ), "20090608/20096810374579.jpg");
string temp = "xxxxxxxxhttp://pic.jinti.com/member/7326419/20096810374579.jpg";
string Result=temp.Replace(temp.Substring(temp.LastIndexOf("http://pic.jinti.com/member/") + "http://pic.jinti.com/member/".Length ), "20090608/20096810374579.jpg");
update list
set context=
REPLACE('http://pic.','pic.','pic3.')
+REPLACE('jinti.com/member/','member/','album/')
+left(substring(context,charindex('member',context)+6+len(用户ID)+2,len(context)-(charindex ('member',context)+6+len(用户ID)+1)),6)+'/'
+substring(context,charindex('member',context)+6+len(用户ID)+2,len(context)-(charindex('member',context)+6+len(用户ID)+1))
where context like '%http://pic.jinti.com/member/%测试code :
declare @s varchar(100)
declare @ID varchar(100)
set @ID='7326419'
set @s='http://pic.jinti.com/member/7326419/20096810374579.jpg'
set @s = REPLACE('http://pic.','pic.','pic3.')+
REPLACE('jinti.com/member/','member/','album/')+
left(substring('http://pic.jinti.com/member/7326419/20096810374579.jpg',charindex('member',@s)+6+len(@ID)+2,len(@S)-(charindex('member',@s)+6+len(@ID)+1)),6)+'/'+
substring('http://pic.jinti.com/member/7326419/20096810374579.jpg',charindex('member',@s)+6+len(@ID)+2,len(@S)-(charindex('member',@s)+6+len(@ID)+1))
print @S