replace - Reference Guide - Cortex XSIAM - Cortex - Security Operations

Cortex XSIAM XQL Language Reference

Product
Cortex XSIAM
Creation date
2023-10-30
Last date published
2024-03-27
Category
Reference Guide
Abstract

Learn more about the Cortex Query Language replace() function that performs a substring replacement.

Syntax

replace (<field>, "<old_substring>", "<new_string>")

Description

The replace() function accepts a string field, and replaces all occurrences of a substring with a replacement string.

Examples

If '.exe' is present on the action_process_image_name field value, replace that substring with an empty string. This example uses the if and lowercase functions, as well as the contains operator to perform the conditional check.

dataset = xdr_data 
| fields action_process_image_name as apin 
| filter apin != null 
| alter remove_exe_process = if(lowercase(apin) contains ".exe",
                              replace(lowercase(apin),".exe",""),
                              lowercase(apin)) 
| limit 10

See also the trim function example.