Closed Thread
Results 1 to 5 of 5

Thread: Another Problem

  1. #1
    Chan is offline Programming Professional
    Join Date
    Jun 2006
    Posts
    205
    Rep Power
    0

    Another Problem

    I would like to search for text in a string and then replace the values like notepad does. How do I do this without parsing the entire string char by char?

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    hoser2001's Avatar
    hoser2001 is offline Programmer
    Join Date
    Jul 2006
    Posts
    175
    Rep Power
    0
    C# has a few methods particularly for this...

    you are going to want to use the indexof property...

    I believe it is something a long the lines of string.indexof("stringtofind")

    this can be used with many other properties and functions to get you what you need. I don't have the time to look up all of them but maybe this will point you in the right dirrection.

  4. #3
    brackett is offline Programmer
    Join Date
    May 2006
    Posts
    192
    Rep Power
    22
    System.String.Replace if you don't need anything fancy.

    Otherwise, look into the System.Text.RegEx (Regular Expressions) namespace.

  5. #4
    Chan is offline Programming Professional
    Join Date
    Jun 2006
    Posts
    205
    Rep Power
    0
    So I just use code like

    Code:
    text = System.String.Replace("text","string");

  6. #5
    Lop's Avatar
    Lop
    Lop is offline Speaks fluent binary
    Join Date
    May 2006
    Posts
    1,178
    Rep Power
    30
    Yes

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. If problem or cout problem?
    By chaoticape in forum C and C++
    Replies: 4
    Last Post: 06-10-2011, 10:29 AM
  2. C: Problem with solving problem
    By rakche in forum C and C++
    Replies: 15
    Last Post: 03-28-2010, 01:24 PM
  3. Replies: 0
    Last Post: 04-26-2007, 05:33 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts