【发布时间】:2019-07-08 22:09:04
【问题描述】:
我有一个命令可以输出如下所示的集合字符串:
json.formats[0]].url = "https://example.com/ar.html"
json.formats[1].url = "https://example.com/es.html"
json.formats[2s].url = "https://example.com/ru.html"
json.formats[3].url = "https://example.com/pt.html"
json.formats[73].url = "https://example.com/ko.html"
json.formats[1502].url = "https://example.com/pl.html"
(还有更多实例,但为了简单起见,它们已被删除)
我可以使用下面的命令
myCmd | grep -e 'json\.formats\[.*\]\.url\ \=\ '
但是我只希望通配符匹配整数,并丢弃非整数匹配。它给了我以下信息:
json.formats[0]].url = "https://example.com/ar.html"
json.formats[1].url = "https://example.com/es.html"
json.formats[2s].url = "https://example.com/ru.html"
json.formats[3].url = "https://example.com/pt.html"
json.formats[73].url = "https://example.com/ko.html"
json.formats[1502].url = "https://example.com/pl.html"
我真正想要的是:
json.formats[1].url = "https://example.com/es.html"
json.formats[3].url = "https://example.com/pt.html"
json.formats[73].url = "https://example.com/ko.html"
json.formats[1502].url = "https://example.com/pl.html"
谢谢:-)
【问题讨论】: