Reputation: 91
I need help using regular Expression on Terraform
I usually use lookahead when I want to extract word that is between word to word.
For example. If want to get "DB" from "JMJ-TEMP-DB-SUB-C" or "JMJ-TEMP-DB-SUB-A", I use the regular expression as "[A-Z]+(?=-SUB)"
However, Terraform doesn't support lookahead..
I got an error Invalid function argument as "invalid regexp pattern: invalid or unsupported Perl syntax in (?=."
Please help me with how I can get a word between TEMP and SUB in "JMJ-TEMP-{word}-SUB-C"
If you don't understand my question, aks more please. I will explain in more detail.
Upvotes: 0
Views: 1053
Reputation: 4024
Use the following regex:
TEMP-([A-Z]+)-SUB
And extract the capture group.
Here is a working example of the regex.
Upvotes: 1