我有以下字符串:
"Event: {\"resource\":\"/api/v1/tokens\",\"path\":\"/api/v1/tokens\",\"httpMethod\":\"POST\",\"headers\":{\"Version\":\"HTTP/1.1\",\"User-Agent\":\"PostmanRuntime/7.19.0\",\"Accept\":\"*/*\",\"Postman-Token\":\"4d728c40-a6f8-46fa-9131-2bff7a2c5b69\",\"Host\":\"localhost:8888\",\"Accept-Encoding\":\"gzip, deflate\",\"Connection\":\"keep-alive\",\"cache-control\":\"no-cache\",\"content-type\":\"application/json\"},\"queryStringParameters\":{},\"pathParameters\":null,\"stageVariables\":null,\"requestContext\":{},\"body\":\"{\\n\\t\\\"client_id\\\": \\\"6dd930eb-e4dc-48d9-a18b-ace0c7406234\\\",\\n\\t\\\"secure_client_secret\\\": \\\"fedfc0a7-af1e-413c-ab51-1955113b2b69\\\"\\n}\",\"isBase64Encoded\":false}"
是否可以使用secure
前缀过滤掉所有键和值:
"secure_client_secret\\\": \\\"fedfc0a7-af1e-413c-ab51-1955113b2b69\\\"
答案 0 :(得分:1)
您可以尝试"secure[^:]+:\s*"[^"]+"
说明:
"secure
-正面匹配"secure
[^:]+
-匹配来自:
:
-匹配:
\s*
-匹配零个或多个空格
"[^"]+"
-匹配"
,"
以外的一个或多个字符,然后匹配"