日期:2014-05-18  浏览次数:20730 次

简单问题,等于送分!
sdr(dju123)diwj(254ku)   怎么样
输出(dju123)(254ku)
看谁写的代码最好!

------解决方案--------------------
\([\w]*\)
------解决方案--------------------
System.Console.WriteLine( "sdr(dju123)diwj(254ku) ".Replace( "sdr ", " ").Replace( "diwj ", " "));
------解决方案--------------------
string aa = sdr(dju123)diwj(254ku) sdr(dju123)diwj(254ku) ;

aa = aa.Replace( "( " , "-( " );
aa = aa.Replace( ") " , ")- " );

string[] bb = aa.Split( '- ') ;

aa = " ";

foreach (string cc in bb)
{
if (cc.Length > 0)
{
if (cc.Substring(0, 1) == "( ")
{
aa = aa + cc;
}
}
}

System.Console.WriteLine(aa);

括号里不能有字符 '- '

------解决方案--------------------
string sStr = "sdr(dju123)diwj(254ku) ";
int iOneAFirst=sStr.IndexOf( '( ');
int iOneBFirst = sStr.IndexOf( ') ');
string sFirValue = sStr.Substring(iOneAFirst + 1, iOneBFirst - (iOneAFirst +1));
int iTwoASec = sStr.IndexOf( '( ', iOneAFirst+1);
int iTwoBSec = sStr.IndexOf( ') ', iOneBFirst+1);
string sSecValue = sStr.Substring(iTwoASec + 1, iTwoBSec - (iTwoASec+1));
string sValue = sFirValue + sSecValue;