1.jpg,2.jpg,3.jpg怎样提取前面的数字 比如说我的picturebox2.image=2.jpg;picturebox1.image可能是三张图片的任意一张,假如两个picturebox的图片一样,就消失,如何实现? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 string s = "2.jpg"; MessageBox.Show(s.Substring(0,s.IndexOf('.'))); string str = "1.jpg,2.jpg,3.jpg"; string pattern = @"\d(?=\.\w)?"; Regex regex = new Regex(pattern); MatchCollection mc = regex.Matches(str); foreach (Match m in mc) Console.WriteLine(m.Value); foreach (Match m in mc)=>foreach (Match m in mc.Cast<Match>().Distinct())可以去除重复的。 string str = "1.jpg,2.jpg,3.jpg"; string pattern = @"\d(?=\.\w)?"; Regex regex = new Regex(pattern); MatchCollection mc = regex.Matches(str); foreach (Match m in mc) Console.WriteLine(m.Value); /* * 1 * 2 * 3 * */ LZ 为什么不判断picturebox.image是否相等那?图片前面的一样,并不代表后缀也一样呀,这样可能也不是同一个图片的 string str = "1.jpg,22.jpg,3.jpg"; Regex reg = new Regex(@"\d+"); foreach (Match m in reg.Matches(str)) { Response.Write(m.Value + "<br/>"); } string str = "1.jpg,22.jpg,1.jpg,3.jpg,,22.jpg,3.gif,4.jpg"; Regex reg = new Regex(@"([^,]+)(?!.*?\1)"); foreach (Match m in reg.Matches(str)) { Response.Write(m.Value + "<br/>"); }/*1.jpg3.jpg22.jpg3.gif4.jpg*/ Random rand=new Random();string str1=“2.jpg”;int init=rand.Next(1,3)picturebox2.image=str1;imagepicturebox1.image=“\“"+init+".jpg\"";Console.WriteLine(str1.Substring(0,s.IndexOf('.')));Console.WriteLine(init); (急急急急啊).net 循环替换文章内容的关键字; 多语言的一个疑难杂症,跪求高手解决 asp.net2.0 reportviewer 显示正常,可导出,打印时候出现 unable to load client print control 的提示 请讨论一下豌豆网一键登录的实现思路 谁给帮看看,回答的好的给高分 类不能使用问题 超级难题:希望大家赐教 能否将文本转换为执行代码呢。 怎么能保存当前页面 弹出另一个新页面 而不是刷新原来页面(C#)多谢!!!! .net 开发模式 静态文件触发global.asax事件 PixelFormat包含在哪个命名空间里的?
string s = "2.jpg";
MessageBox.Show(s.Substring(0,s.IndexOf('.')));
string pattern = @"\d(?=\.\w)?";
Regex regex = new Regex(pattern);
MatchCollection mc = regex.Matches(str);
foreach (Match m in mc)
Console.WriteLine(m.Value);
=>
foreach (Match m in mc.Cast<Match>().Distinct())
可以去除重复的。
string str = "1.jpg,2.jpg,3.jpg";
string pattern = @"\d(?=\.\w)?";
Regex regex = new Regex(pattern);
MatchCollection mc = regex.Matches(str);
foreach (Match m in mc)
Console.WriteLine(m.Value);
/*
* 1
* 2
* 3
* */
Regex reg = new Regex(@"\d+");
foreach (Match m in reg.Matches(str))
{
Response.Write(m.Value + "<br/>");
}
Regex reg = new Regex(@"([^,]+)(?!.*?\1)");
foreach (Match m in reg.Matches(str))
{
Response.Write(m.Value + "<br/>");
}
/*
1.jpg
3.jpg
22.jpg
3.gif
4.jpg
*/
string str1=“2.jpg”;
int init=rand.Next(1,3)
picturebox2.image=str1;
imagepicturebox1.image=“\“"+init+".jpg\"";
Console.WriteLine(str1.Substring(0,s.IndexOf('.')));
Console.WriteLine(init);