how to replace a string with another [Resolved]

Posted by Rajendra.prasad under VB.NET on 3/22/2010 | Views : 1689 | Status : [Member] | Replies : 4
how to replace a string with another string as required.
for example: consider a string as "Hello Fall Ball" now replace the char "ll" with char "ee".

consider another example of string as "First Second Third Fourth Fifth". now the output string must be in reverse order "Fifth Fourth Third Second First"

Regards,
Rajendra




Responses

Posted by: SurajRane on: 3/22/2010 [Member] Starter

Up
0
Down

Resolved
Try this one..



string str = "Hello Fall Ball";


str = str.Replace("ll", "ee");


Rajendra.prasad, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sagarp on: 3/23/2010 [Member] Bronze

Up
0
Down
check following

links

http://www.java2s.com/Tutorial/Java/0120__Development/Replaceonestringwithanotherstring.htm

Thanks
SagarP
http://www.emanonsolutions.net
http://emanonsolutions.blogspot.com/

Rajendra.prasad, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lakhangarg on: 3/24/2010 [Member] [Moderator] Silver

Up
0
Down
Hi Rajendra-

For your First Question the solution given by SurajRane will work perfectly.

now for your second query:

string strData="First Second Third Fourth Fifth";

string[] strData1=strData.Split(' ');
string strResult="";
for (int i=strData1.length; i>0; I--)
{
strResult=strData1[i]+ " ";
}

strResult= strResult.Trim();
Response.Write(strResult);


Thanks
Lakhan Pal Garg

Rajendra.prasad, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajendra.prasad on: 3/25/2010 [Member] Starter

Up
0
Down
Lakhan,
not working with the requriement, but seems the logic works fine but need some tuning in proper logic coding.

Regards,
Rajendra

Rajendra.prasad, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response