NAME

Catmandu::Fix::index - Find all positions of a (sub)string in a field

SYNOPSIS

# On strings, search the occurence of a character in a string

# word => "abcde"
index(word,'c')                   # word => 2
index(word,'x')                   # word => -1

# word => "abccde"
index(word,'c', multiple:1)       # word => [2,3]

# word => [a,b,bba] , loop over all word(s) with the '*'
index(word.*,'a')                 # word -> [0,-1,2]

# On arrays, search the occurence of a word in an array

# words => ["foo","bar","foo"]
index(words,'bar')                # words => 1
index(words,'foo', multiple: 1)   # words => [0,2]

SEE ALSO

Catmandu::Fix