REGEX_MATCH_POSITION

Matches the regular expression on the input string, and returns the index of the first match.

Syntax

REGEX_MATCH_POSITION(pattern, value, startPosition)

Arguments

Name

pattern

value

startPosition

Returns

Returns a bigint value.


Examples

patternvaluestartPositionOutput

','

'1,2,3'

0

1

'2,\d'

'1,2,3'

2

2

'2,\d'

'1,2,3'

3

null

','

'1,2,3'

-1

null

','

'1,2,3'

-2

3

Transformation job example

SQL

CREATE JOB function_operator_example
    ADD_MISSING_COLUMNS = true
AS INSERT INTO default_glue_catalog.upsolver_samples.orders_transformed_data 
  MAP_COLUMNS_BY_NAME
    SELECT pattern, value, startPosition,
        REGEX_MATCH_POSITION(',', value, startPosition) AS Output
    FROM default_glue_catalog.upsolver_samples.orders_raw_data
    LET pattern = ',',
        value = '1,2,3',
        startPosition = 0
    WHERE $commit_time BETWEEN run_start_time() AND run_end_time()
    LIMIT 1;

Query result

patternvaluestartPositionOutput

','

'1,2,3'

0

1

Last updated