Replacing a String
Function Name
$strReplace(String str, String old, String replace, boolean isRegular)
Parameter Description
- str: Accepts a string, local parameter, environment parameter, or built-in function.
- old: Accepts a string, local parameter, environment parameter, or built-in function.
- replace: Accepts a string, local parameter, environment parameter, or built-in function.
- replace: Accepts true or false to indicate whether to use a regular expression for replacement. If it is set to true, the old parameter accepts regex.
Function Description
Replaces a URL request parameter value or part of the value and assigns the value to the str parameter.
Application Scenarios
This function can be used in the following parts of an API automation test case. (Do not use the function for environment parameters. Otherwise, what is input will be output.)
- Request URL
- Request header
- Request body
- Checkpoint property
- if condition
- for loop interrupt condition
Example
- Request URL
As shown in the URL request in Figure 2, the string replacement function is used in the request body to replace the value of the environment parameter New_Variable_2 and assign the new value to keyword.
After saving and running the script, you can view the details in the execution history.

What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot
