-1

How can we do a multi match in re2?

below is the url i want to apply regex on

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

below is my code

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

I am able to replace

https://

with

""

i also need to get rid of

/new_stage

How can i achieve both in single line

Shane Warne
  • 1,350
  • 11
  • 24
  • tried the above solution. c43545332542.us-east-1.amazonaws.com/new_stage, Only https:// part was removed . /new_stage remains. I only need "c43545332542.us-east-1.amazonaws.com" – Shane Warne Oct 23 '18 at 15:01
  • https://regex101.com/ –  Oct 23 '18 at 15:13
  • hey @Corion i was able to solve this by adding /(?i)https://([^/]+).*/*/ to your solution. this .*/* allowed me to remove the / and string after .com. You can post your answer . I will verify it. – Shane Warne Oct 24 '18 at 11:17

1 Answers1

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.

Corion
  • 3,855
  • 1
  • 17
  • 27