Filter values from list using multiple patters

Hello,

I receiving following list form external data resource:

my_list = [
  "dev-app1",
  "dev-app2",
  "test-app1",
  "test-app2",
  "prod-app1",
  "prod-app2"
]

Which elements are dynamic and cannot be predicted. So I’m need to exclude all elements which consist two patterns like dev-* and test-* to receive:

my_list = [
  "prod-app1",
  "prod-app2",
  "prod-xxx",
]

Could you please advice how to achieve this?

Use a for expression with a filtering clause: https://developer.hashicorp.com/terraform/language/expressions/for#filtering-elements

Use the startswith or regexall function to as part of the filtering clause you write: https://developer.hashicorp.com/terraform/language/functions/startswith, https://developer.hashicorp.com/terraform/language/functions/regexall