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.Splunk SPL users
Splunk SPL users
In Splunk SPL, reversing strings typically requires custom functions or scripts. APL’s
reverse provides this functionality natively.ANSI SQL users
ANSI SQL users
In ANSI SQL, string reversal varies by database with different functions. APL’s
reverse provides standardized string reversal.Usage
Syntax
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| value | string | Yes | The 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.QueryRun in PlaygroundOutput
This query detects palindromic URIs by comparing them with their reversed versions, which can help identify unusual or test data patterns.
| method | palindrome_count | total_count | palindrome_percentage |
|---|---|---|---|
| GET | 12 | 8765 | 0.14 |
| POST | 5 | 2341 | 0.21 |
| PUT | 2 | 987 | 0.20 |
List of related functions
- 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.