如何使用正则表达式将JSON值与jq匹配?

时间:2018-03-30 00:11:16

标签: json regex jq

我的JSON数据:

[
  "delivery_1b36940ef75c49a8864d8cb3ea6a3a9f",
  "toPayBtn_10021",
  "item_fdd0772d0dd74dea93033761ca14e781",
  "item_4f1a3f6fd3afdb940be008a0d325f9ad",
  "delivery_d69dc5e9df971c9b2b1736c2231cb4a9",
  "orderTotal_1",
  "address_BILLING#1",
  "delivery_185e36d98d5e4cc1808e59e44df8c71c",
  "voucherInput_1",
  "address_DELIVERY#1",
  "item_864e1a7daf2aa424cbcb2251d55abda9",
  "item_913196f953cbe8cfc2851c8fa9498607"
]

我希望与toPayBtn_10021匹配,但toPayBtn_之后的数字是动态的,可以是toPayBtn_10 toPayBtn_2 toPayBtn_847等... 我试过了

jq '.toPayBtn_*'

但它不起作用,我该如何解决?

1 个答案:

答案 0 :(得分:1)

.[] | select( test("^toPayBtn_") )