HELP: pair-value search & replace
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: HELP: pair-value search & replace

  1. #1
    Join Date
    Mar 2009
    Posts
    15

    HELP: pair-value search & replace

    Does anyone know to quickly make a multiple search & replace app (in either C or C++)? Am not interested in searching multiple files, just one file. I want to translate a list of unicode characters into something else (pair-value lookup table) ... so it's basically a crude/naive translator!

    I just need a quick pseudocode to get me started. Or maybe there's an opensource/free code already written?

    PS: Or maybe it's easier quicker with sed/awk/perl?

  2. #2
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Fairfax, VA
    Posts
    10,885

    Re: HELP: pair-value search & replace

    1) Read the entire file into a single std::string.
    2) Use std::string::find_first_of() repeatedly to find the next substring of interest.
    3) Copy the intermediate portion of the string to another std::string (output).
    4) Pull the relevant replacement substring from a std::map<std::string,std::string>.
    5) Concatenate the replacement substring onto the output string.
    6) Go to 2 until done.
    7) Write the output string back to a file.

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center