fpoyavo
asked on
REPLACE 4
Hi Experts,
How can I replace "{" and / or "}" in my string with spaces " " ?
I have tried some things :
Regex.Replace(mystr, @"}", @""); and
my(mystr).Replace('{', ' ');
It does not help.
Thank you.
How can I replace "{" and / or "}" in my string with spaces " " ?
I have tried some things :
Regex.Replace(mystr, @"}", @""); and
my(mystr).Replace('{', ' ');
It does not help.
Thank you.
fpoyavo,
string functions do not modify the string itself. If you'd use:
mystr = Regex.Replace(mystr, @"}", @"");
then it would be replaced.
string functions do not modify the string itself. If you'd use:
mystr = Regex.Replace(mystr, @"}", @"");
then it would be replaced.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
string s = "How can I replace { and / or } in my string with spaces ?";
Console.WriteLine("String before Replace : " + s);
s = s.Replace("{" , " ").Replace("}", " ").Replace("/"," ");
Console.WriteLine("String after Replace : " + s);
and heres the output:
String before Replace : How can I replace { and / or } in my string with spaces ?
String after Replace : How can I replace and or in my string with spaces ?
Cheers!
Fahad Mukhtar
Console.WriteLine("String before Replace : " + s);
s = s.Replace("{" , " ").Replace("}", " ").Replace("/"," ");
Console.WriteLine("String after Replace : " + s);
and heres the output:
String before Replace : How can I replace { and / or } in my string with spaces ?
String after Replace : How can I replace and or in my string with spaces ?
Cheers!
Fahad Mukhtar
using System;
using System.Text.RegularExpress ions;
string myString;
myString = "This is a test.";
myString = Regex.Replace(myString, " is", " was");
using System.Text.RegularExpress
string myString;
myString = "This is a test.";
myString = Regex.Replace(myString, " is", " was");
mystr=mystr.Replace(Conver
this.Label1.Text=mystr;
http://www.codetoad.com/ascii_characters_asp.asp