Reputation: 5085
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!
Upvotes: 0
Views: 1477
Reputation: 5085
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!
Upvotes: 2
Reputation: 9209
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>";
Upvotes: 1
Reputation: 124632
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>"
Upvotes: 3
Reputation: 8876
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
Upvotes: 3
Reputation: 7392
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.
Upvotes: 3