如何在 re2 正则表达式中使用多匹配



我们如何在 re2 中进行多重匹配?

下面是我想应用正则表达式的网址

https://c43545332542.us-east-1.amazonaws.com/new_stage

下面是我的代码

value = "${replace(aws_api_gateway_deployment.deployment.invoke_url,"/(?i)https:///","")}"

我可以更换

https://

">

我还需要摆脱

/new_stage

如何在单行中实现两者

尝试以下正则表达式:

value = "${replace(aws_api_gateway_deployment.deployment.invoke_url,"/(?i)https://([^/]+).*/*/","$1")}"

这应该可以帮助您匹配和更换所需的零件。