急◎◎如何取出asdsd[dfsdfdsfk]中方括号中的字符!!!!

网_风 2004-08-13 05:45:41
如何取出字符串asdsd[dfsdfdsfk]方括号中的字符!!!!
...全文
153 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
realljx 2004-08-17
  • 打赏
  • 举报
回复
老兄 在我这里测试没有问题。接分。
realljx 2004-08-17
  • 打赏
  • 举报
回复
string a ="asd[asd]"
string pattern = @"[\s\S]*?\[([\s\S]*?)\][\S\s]*";

string res = a;
Match m = Regex.Match(a,pattern);
if(m.Success)
{
a = m.Groups[1].Value;
}
网_风 2004-08-17
  • 打赏
  • 举报
回复
我要的是正则表达式处理方法!
网_风 2004-08-17
  • 打赏
  • 举报
回复
没有人知道吗
网_风 2004-08-16
  • 打赏
  • 举报
回复
没有人知道吗
xaodoudou 2004-08-15
  • 打赏
  • 举报
回复
写了半天 没测出来,顶一顶吧
chengjunlin55555 2004-08-15
  • 打赏
  • 举报
回复
ggh
网_风 2004-08-15
  • 打赏
  • 举报
回复
不好意思。
我要的是正则表达式处理方法!
TalosChen 2004-08-13
  • 打赏
  • 举报
回复
还是偶得最简单嘛
leoAAAA 2004-08-13
  • 打赏
  • 举报
回复
高手真多,学习!
TalosChen 2004-08-13
  • 打赏
  • 举报
回复
string[] split="asdsd[dfsdfdsfk]".Split(new char[] {'[',']'});
"dfsdfdsfk"==split[1]
flashasp 2004-08-13
  • 打赏
  • 举报
回复
string ss2="asdsd[dfsdfdsfk]";
ss2=ss2.Remove(0,ss2.LastIndexOf(@"["));
ss2=ss2.Replace("[","");
ss2=ss2.Substring(0,ss2.IndexOf(@"]"));
Response.Write(ss2);
wangsaokui 2004-08-13
  • 打赏
  • 举报
回复
Sorry!

string a="asdsd[dfsdfdsfk]";
int pos_s,pos_e;
pos_s = a.IndexOf("[");
pos_e = a.IndexOf("]");

string b=a.Substring(pos_s+1,pos_e-pos_s-1);
MessageBox.Show(a+"||"+ b);
tianjue0921 2004-08-13
  • 打赏
  • 举报
回复
谁写个正则来看看。
bcqingteng 2004-08-13
  • 打赏
  • 举报
回复
....
大家同一时间嘛
bcqingteng 2004-08-13
  • 打赏
  • 举报
回复
s= "asdsd[as]";
s = s.substring(s.indexof("[") + 1,s.indexof("]") - s.indexof("[") -1);
realljx 2004-08-13
  • 打赏
  • 举报
回复
string a = "asdsd[dfsdfdsfk]"
a.Substring(a.Indexof("[")+1,a.Indexof("[")-a.Indexof("]"-1)
孟子E章 2004-08-13
  • 打赏
  • 举报
回复
用Str.Substring()或者正则
wangsaokui 2004-08-13
  • 打赏
  • 举报
回复
string a="asdsd[dfsdfdsfk]";
int pos_s,pos_e;
pos_s = a.indexof("[");
pos_e = a.indexof("]");

string b=substring(a,pos_s+1,pos_e-1);

62,025

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧