字符串拆分以从字符串中获取特定值? [英] string split to fetch particular value from a string ?

查看:87
本文介绍了字符串拆分以从字符串中获取特定值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮我从字符串中获取特定值。

字符串格式如下:



string s =

(Noshow =广告|吸引=

N \\013 \\abc.swf;

N \\ 012 \\\def.jpg)



i只想获取abc.swf和def.jpg。



任何人都可以建议我使用正则表达式来获取\\和;之间的值或者任何其他方式。

Please help me to fetch particular values from a string .
String is in format gine below ,

string s =
(Noshow=Ads|Attract=
N\\013\\abc.swf;
N\\012\\def.jpg)

i want to fetch only abc.swf and def.jpg .

Anyone can suggest me a regex to fetch value between "\\" and ";" or any other way .

推荐答案

这似乎有用(在.net中):(?< = \\\\\ \\)[^; \\\)] *?(?=; | \))



http://msdn.microsoft.com/en-us/library/az24scfc.aspx [ ^ ]
This seems to work (in .net): (?<=\\\\)[^;\\\)]*?(?=;|\))

http://msdn.microsoft.com/en-us/library/az24scfc.aspx[^]


你可以试试这个: -



You can try this:-

string text = "(Noshow=Ads|Attract=N\\013\\abc.swf;N\\012\\def.jpg"; //Put your string
string answerStr = myString .Split('\\', ';')[1];


这篇关于字符串拆分以从字符串中获取特定值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆