我如何在Re2正则表达式中为Terraform使用多重匹配

时间:2018-10-23 14:22:43

标签: regex terraform 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

我如何在单行中同时实现这两者

1 个答案:

答案 0 :(得分:1)

Try the following regular expression:

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

This should help you match and replace the parts that you need.