Skip to content

scan() with grouping returns empty string #14

Open
@voke

Description

@voke

I'm having a case where scan() returns empty string.

Using the jq command:

echo '{ "foo": "thisthat" }' | jq '.foo | scan("this(.+)")'

Output:

[
  "that"
]

Using ruby-jq gem:

irb(main):001:0> require 'jq'
=> true
irb(main):002:0> JQ::VERSION
=> "0.2.1"
irb(main):002:0> JQ('{ "foo": "thisthat" }').search('.foo | scan("this(.+)")')
=> [[""]]

I can only reproduce the problem when deployed to heroku. To reproduce the problem click the deploy button at https://github.com/voke/heroku-jq-debugger (which includes the libjq 1.6 buildpack)

Run heroku run console --app YOUR_APP_NAME and follow the steps above.


First I thought it must be an oniguruma issue since regexp is used. But gsub command works as expected.

My second guess was that since my local version of jq (installed via homebrew) and the ruby-jq gem returns the correct output the problem must be within my buildpack. But running the jq command at heroku also returns the correct output.

heroku run "cd jq && echo '{ \"foo\": \"thisthat\" }' | ./jq '.foo | scan(\"this(.+)\")'" --app YOUR_APP_NAME

Output:

[
  "that"
]

Do you have any idea what the issue may be?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions