`.index` is going to be the fastest because it is directly using NQP
ops which are built into the VM.

    'abcdefg'.index('de'); # 3

If you want all of the indexes, use `.indices`

    'abcdefabc'.indices('abc'); # 0, 6

`.index` will return `Nil` if it doesn't find anything, and `.indices`
will return an empty list.

    'abc'.index('ZZ'); # Nil
    'abc'.indices('ZZ'); # ()

To see the actual code implementing these (and other similar methods):

- .index: 
- .indices: 
- .contains: 
- .rindex: 

On Sat, Feb 2, 2019 at 5:13 AM ToddAndMargo via perl6-users
<perl6-users@perl.org> wrote:
> Hi All,
> What is the fastest way to find the index of
> a sub string in a string?
> -T

Reply via email to