Find and replace within a string?

This is a discussion on Find and replace within a string? within the C Programming forums, part of the General Programming Boards category; Hi, Is there a STL function that lets me pass a full string, a substring to find and a substring ...

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    38

    Find and replace within a string?

    Hi,
    Is there a STL function that lets me pass a full string, a substring to find and a substring to replace it with?
    I will illustrate with an example:
    I have a string like this: PCGI1.BATCH.CTL.OD.SEW4137.D
    In that string I want to find the substring "CTL" and replace it with the substring "CDR"
    Is there an existing function to do this in the STL that anyone knows of, and if not can anyone suggest a solution; I seem to be suffering from brain deadedness (as proven by the use of the word deadedness) and just cant see a solution.
    Thanks

  2. #2
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,424
    STL is C++. Why you are asking question on C-forum?
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    38
    I thought there was an STL in C as well? If not then just replace STL with standard library of functions or whatever it is you want to call it; fred, george, betty its entirely up to you.

  4. #4
    Registered User
    Join Date
    Dec 2001
    Posts
    38
    Its alright, my brain has woken up again, all done.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to find and replace a string in a file
    By salzouby in forum C Programming
    Replies: 13
    Last Post: 09-14-2010, 08:55 AM
  2. String replace
    By guitarist809 in forum C++ Programming
    Replies: 2
    Last Post: 04-10-2008, 03:53 PM
  3. Errors with program to replace string with another
    By Dan17 in forum C Programming
    Replies: 3
    Last Post: 09-14-2006, 10:15 AM
  4. Replies: 5
    Last Post: 05-25-2004, 04:36 PM
  5. Find and Replace Text Function
    By mart_man00 in forum C Programming
    Replies: 45
    Last Post: 03-13-2003, 09:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21