Concatenate environment variable with Regex in Python [duplicate]

  python, regex

I want to pass variable to a regex to match domains in different environment, how to proceed concatenation on regex with python

os.getenv("DOMAIN") -> example.com

my current regex

 r"^https://.*.example.com$"

What is expected

r"^https://.*.' + os.getenv("DOMAIN") + '$"

Source: Python Questions

LEAVE A COMMENT