tags:

views:

170

answers:

5
string s1 = "[quote=useruk1]<p>im useruk1</p>[/quote]<p>hi  im mod1-probe</p>";
string s2 = "hi  im mod1-probe";
string s3 =  "blah blah";
string s4 = s1.Replace(s2, s3);
Console.Write(s4);

seems to be not working. Any ideas? How to solve this problem?

UPDATE:

problem was with the space, normal space ASCII value is 32 and above string ASCII value was 160 so i did a

s1 = Regex.Replace(s1, @"\u00A0", " ");

everthing worked fine ! thanks a lot guys!

+3  A: 

When I run the code, the output is this:

[quote=useruk1]<p>im useruk1</p>[/quote]<p>blah blah</p>

Isn't that what you'd expect?

Edit: Ah yeah... as Paul points out, space vs. tab would explain it.

Igor ostrovsky
+3  A: 

Getting output as [quote=useruk1]<p>im useruk1</p>[/quote]<p>blah blah</p>.

Check the space between hi and im in "hi im mod1-probe" in s2 and s1

Himadri
+3  A: 

It does work. I literally copied this code from your post

string s1 = "[quote=useruk1]<p>im useruk1</p>[/quote]<p>hi  im mod1-probe</p>";
string s2 = "hi  im mod1-probe";
string s3 =  "blah blah";
string s4 = s1.Replace( s2, s3 );
Console.Write( s4 );
Console.ReadLine( );

and pasted it into a new project. My result was:

"[quote=useruk1]<p>im useruk1</p>[/quote]<p>blah blah</p>"
Ed Swangren
+1  A: 

In order to prevent any possible misinterpretation of "/p" I would have:

string s1 = @"[quote=useruk1]<p>im useruk1</p>[/quote]<p>hi  im mod1-probe</p>";
ChrisBD
A: 

problem was with the space,

normal space ASCII value is 32 and above string ASCII value was 160

so i did a

s1 = Regex.Replace(s1, @"\u00A0", " ");

everthing worked fine !

thanks a lot guys!

kakopappa