Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Replace a character in a string.

Reply
Thread Tools

Replace a character in a string.

 
 
Venkat
Guest
Posts: n/a
 
      12-15-2003
Greetings,

I got a string like this str = {1234-4543-6453-ACBD-AFEB} now i need to have
an output like str = 1234-4543-6453-ACBD-AFEB, basically i want to remove
the characters
'{' and '}'.

here is the code....

vector<string> Temp;

//Fill the elements in Temp
........................
.........................

//Read the elements from Temp

for (int l = 0; l < Temp.size(); ++l)
{
std::string str= Temp[l].c_str();

}


Now str outputs the values with character '{' and '}' i need it to output
values without these characters.


Pl Help.


Regards,
Venkat




 
Reply With Quote
 
 
 
 
lallous
Guest
Posts: n/a
 
      12-15-2003
"Venkat" <(E-Mail Removed)> wrote in message
news:1071469855.463813@sj-nntpcache-5...
> Greetings,
>
> I got a string like this str = {1234-4543-6453-ACBD-AFEB} now i need to

have
> an output like str = 1234-4543-6453-ACBD-AFEB, basically i want to remove
> the characters
> '{' and '}'.
>
> here is the code....
>
> vector<string> Temp;
>
> //Fill the elements in Temp
> .......................
> ........................
>
> //Read the elements from Temp
>
> for (int l = 0; l < Temp.size(); ++l)
> {
> std::string str= Temp[l].c_str();
>
> }
>
>
> Now str outputs the values with character '{' and '}' i need it to output
> values without these characters.
>
>
> Pl Help.
>
>
> Regards,
> Venkat


std::string newstr = s.substr(1, s.length()-2);

--
Elias


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace /n with a XHTML <br /> using string.replace Alun ASP .Net 3 02-18-2008 05:52 AM
How can I replace all occurrences of a character with another character in std string? herman C++ 5 08-30-2007 09:05 AM
Re: [Pyrex] pyrex functions to replace a method (Re: replace a method Greg Ewing Python 2 06-29-2006 05:25 PM
pyrex functions to replace a method (Re: replace a method in class:how?) Brian Blais Python 1 06-27-2006 12:13 PM
help with string replace - for doing selective replace Prasad S Javascript 2 08-27-2004 03:22 PM



Advertisments