Skip to content

indices behaves differently when dealing with arrays vs strings #3030

Closed
@kklingenberg

Description

@kklingenberg

Describe the bug

Not sure if it is a bug. The behaviour of indices differs when given arrays vs strings when the matches overlap.

To Reproduce

[0, 0, 0] | indices([0, 0]) == [0, 1]

vs.

"aaa" | indices("aa") == [0]

Expected behavior

Both cases should match, or if the difference is intented the string case should be documented.

Environment (please complete the following information):

  • OS and Version: Ubuntu 22.04
  • jq version 1.7

Additional context

Related issue in jaq: 01mf02/jaq#154

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions