isstr()

The isstr() function checks whether the value passed as an argument is a string type and returns a boolean.

Syntax

isstr(EXPR)

Parameters

EXPR
A field name or expression whose type to check.

Description

The isstr() function returns true if the result of evaluating EXPR is a string type, and false otherwise.

If the result of evaluating EXPR is null, returns false because null is not a string.

Error codes

N/A

Usage examples

To prepare the WEB_APACHE_SAMPLE table used in these examples, refer to Preparing sample data.

  1. Checking the string-type method field

    table limit=5 WEB_APACHE_SAMPLE | eval result = isstr(method) | fields method, result
    | # result: true
    
  2. Checking the integer-type status field

    table limit=5 WEB_APACHE_SAMPLE | eval result = isstr(status) | fields status, result
    | # result: false
    
  3. NULL input

    json "{'val': null}" | eval result = isstr(val)
    | # result: false
    

Compatibility

The isstr() function has been available since before Sonar 4.0.