Skip to main content
The reverse function reverses the order of characters in a string. Use this function to analyze strings from right to left, detect palindromes, or transform data for specific pattern matching requirements.

For users of other query languages

If you come from other query languages, this section explains how to adjust your existing queries to achieve the same results in APL.
In Splunk SPL, reversing strings typically requires custom functions or scripts. APL’s reverse provides this functionality natively.
| eval reversed=mvreverse(split(field, ""))| eval reversed=mvjoin(reversed, "")
In ANSI SQL, string reversal varies by database with different functions. APL’s reverse provides standardized string reversal.
SELECT REVERSE(field) AS reversed FROM logs;

Usage

Syntax

reverse(value)

Parameters

NameTypeRequiredDescription
valuestringYesThe input string to reverse.

Returns

Returns the input string with its characters in reverse order.

Use case examples

  • Log analysis
  • OpenTelemetry traces
  • Security logs
Detect palindromic patterns in URIs or identifiers for data validation.Query
['sample-http-logs']
| extend reversed_uri = reverse(uri)
| extend is_palindrome = uri == reversed_uri
| summarize palindrome_count = countif(is_palindrome), total_count = count() by method
| extend palindrome_percentage = round(100.0 * palindrome_count / total_count, 2)
| sort by palindrome_count desc
Run in PlaygroundOutput
methodpalindrome_counttotal_countpalindrome_percentage
GET1287650.14
POST523410.21
PUT29870.20
This query detects palindromic URIs by comparing them with their reversed versions, which can help identify unusual or test data patterns.
  • substring: Extracts parts of strings. Use this with reverse to extract from the end of strings.
  • strlen: Returns string length. Use this with reverse for position calculations from the right.
  • strcat: Concatenates strings. Use this to build strings with reversed components.
  • split: Splits strings into arrays. Use this with reverse to process tokens in reverse order.