Click here to Skip to main content
15,912,932 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

My editor have content like bellow.

Test URLs
http://www.apple.com/
http://www.apple.com/ipod
http://www.apple.com/iphone/

In the above three lines i want to replace http://www.applie.com to some other Url like(http://www.google.com). I Used Replace function to modifed above 3 lines to like bellow

http://www.google.com/
http://www.google.com/ipod
http://www.google.com/iphone/

But i want to modify only first Line not for all lines

please give me any suggestion for this issue.

Thanks,
Posted
Comments
What code you have implemented ?
Samresh.ss 24-May-13 5:47am    
I think he is using search and replace in an editor and not in code.
swaroop1069 24-May-13 9:43am    
ya exactly i search http://www.apple.com/ url and replace only this url not for remain urls.

1 solution

C#
string str="http://www.apple.com/";
if (TestURIStr.Equals(str)
{
  string replacestr = TestURIStr.Replace(TestURIStr,"http://www.google.com/");
}
else
{
  string replacestr = TestURIStr;
}


-NP
 
Share this answer
 
Comments
swaroop1069 24-May-13 9:02am    
hi,

you con't understood my question for example in the above string take like
string str="http://www.apple.com xxxxx http://www.apple.com/level";
If Execute above code replace two urls in the string. But i want Exact Replace, Only replace first URL not for 2nd URL, 2nd URL contacts extra info like '/level' this is main problem we are faced.
Samresh.ss 24-May-13 12:23pm    
You can use regex

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900