---
name: "Catmandu::Fix::index"
section: "3pm"
platform: "linux"
package: "libcatmandu-perl"
version: "1.2024-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Catmandu::Fix::index"
---

# Catmandu::Fix::index(3pm)

Find all positions of a (sub)string in a field

## 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
