Skip to content

JayTwoLab/replace_std_string

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

replace_std_string

  • string replacement function for std::string

Function

namespace j2 {
 std::string replace(const std::string& text,
                     const std::string& find_token,
                     const std::string& replace_token);
}

How to use

int main()
{
    std::string before = "hello\tworld\r\n123\n456";
    std::string strFind = "\r\n";
    std::string strReplace = "";

    std::cout << "Before : "<< before << std::endl << std::endl;
    std::string after = j2::replace(before, strFind, strReplace);
    std::cout << "After : " << after << std::endl;

    /*
    Before : hello	world
    123
    456

    After : hello	world123
    456
    */

    return 0;
}

License

About

Replacement function for C++ std::string

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published