我要评分
获取效率
正确性
完整性
易理解

ReplaceAllAcc

Function Usage

Performs string match and Replace All operations according to the fixed regular expression rule "[^A-Za-z0-9_/.]+" based on the shufti algorithm.

Function Syntax

std::string ReplaceAllAcc(const std::string& input, const std::string& replacement) 

Parameters

Parameter

Description

Value Range

Input/Output

input

Input string (string to be replaced)

C++ string object, which can be null.

Input

replacement

Replacement string

C++ string object, which can be null.

Input

Return Value

String after the Replace All operation is performed.

The input string is not modified.

Example

  1. Create a testReplaceAll.cpp file.
  2. Press i to enter the insert mode and add the following content to the file:
    #include "khsel_ops.h"
    #include <iostream>
    
    int main() {
        std::string input = "Hello*#$&@Hello12345!()";
        std::string replacement = "hi";
        std::cout << ReplaceAllAcc(input, replacement) << std::endl;
        return 0;
    }
  3. Press Esc, type :wq!, and press Enter to save the file and exit.
  4. Compile the testReplaceAll.cpp file and specify the name of the output executable file as testReplaceAll.
    g++ testReplaceAll.cpp -o testReplaceAll -I /usr/local/ksl/include -L /usr/local/ksl/lib -lKHSEL_ops
  5. Run the testReplaceAll executable file.
    ./testReplaceAll
    The execution result is as follows:
    HellohiHello12345hi