Man pages sections > man3 > Catmandu::Fix::index

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

Catmandu::Fix::index(3pm) User Contributed Perl Documentation Catmandu::Fix::index(3pm)

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
2017-10-01 perl v5.26.0