This page explains how to use the regex_quote function in APL.
regex_quote
function in APL when you need to safely insert arbitrary string values into regular expression patterns. This function escapes all special characters in the input string so that it is interpreted as a literal sequence, rather than as part of a regular expression syntax.
regex_quote
is especially useful when your APL query constructs regular expressions dynamically using user input or field values. Without escaping, strings like .*
or [a-z]
would behave like regex wildcards or character classes, potentially leading to incorrect results or vulnerabilities. With regex_quote
, you can ensure the string is treated exactly as-is.
Splunk SPL users
re.escape()
function is not available natively in SPL, so you often handle escaping in external scripts or manually. In APL, regex_quote
provides built-in support for quoting regular expression metacharacters.ANSI SQL users
regex_quote
handles all necessary escaping for you, making regex construction safer and more convenient.Name | Type | Description |
---|---|---|
value | string | The input string to be escaped for regex safety. |
uri
contains an exact match of a user-provided pattern, such as /api/v1/users[1]
, which includes regex metacharacters. Use regex_quote
to safely escape the pattern before matching.Query_time | id | uri | status |
---|---|---|---|
2025-06-10T15:42:00Z | user-293 | /api/v1/users[1] | 200 |
uri
exactly matches the string /api/v1/users[1]
, without interpreting [1]
as a character class.