Find and replace string in body
APPLIES TO: All API Management tiers
The find-and-replace
policy finds a request or response substring and replaces it with a different substring.
Note
Set a policy's elements and child elements in the order provided in the policy statement. Learn more about how to set or edit API Management policies.
Policy statement
<find-and-replace from="what to replace" to="replacement" />
Attributes
Attribute | Description | Required | Default |
---|---|---|---|
from | The string to search for. Policy expressions are allowed. | Yes | N/A |
to | The replacement string. Specify a zero length replacement string to remove the search string. Policy expressions are allowed. | Yes | N/A |
Usage
- Policy sections: inbound, outbound, backend, on-error
- Policy scopes: global, workspace, product, API, operation
- Gateways: classic, consumption, self-hosted
Example
<find-and-replace from="notebook" to="laptop" />
Related policies
Next steps
For more information about working with policies, see:
- Tutorial: Transform and protect your API
- Policy reference for a full list of policy statements and their settings
- Policy expressions
- Set or edit policies
- Policy samples