[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

REPLACE 4

Posted on 2004-10-06
5
Medium Priority
?
266 Views
Last Modified: 2010-05-18
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.
0
Comment
Question by:fpoyavo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 15

Expert Comment

by:praneetha
ID: 12240617
string mystr="hello {fhjsdhfjs";
                  mystr=mystr.Replace(Convert.ToChar(123),Convert.ToChar(32));
                  this.Label1.Text=mystr;


http://www.codetoad.com/ascii_characters_asp.asp
0
 
LVL 8

Expert Comment

by:Razzie_
ID: 12240844
fpoyavo,

string functions do not modify the string itself. If you'd use:

mystr = Regex.Replace(mystr, @"}", @"");

then it would be replaced.
0
 
LVL 9

Accepted Solution

by:
s_sansanwal earned 2000 total points
ID: 12244850
Try

string test = "name{-}microsoft";
test = System.Text.RegularExpressions.Regex.Replace(test, @"[{\}]", " ");


Cheers,
S Sansanwal
0
 
LVL 19

Expert Comment

by:Fahad Mukhtar
ID: 12245646
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
0
 
LVL 4

Expert Comment

by:Tasneem
ID: 12247899
using System;
using System.Text.RegularExpressions;

string myString;
myString = "This is a test.";
myString = Regex.Replace(myString, " is", " was");
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question