Environment Variable Regex

Matches environment variable declarations like KEY=value.

パターン

/^([A-Z_][A-Z0-9_]*)=(.*)$/gm
→ ビジュアライザーで開く

テスト例

DATABASE_URL=postgres://localhost/db API_KEY=abc123 PORT=3000 invalid-key=value

コード例

javascript

const regex = /^([A-Z_][A-Z0-9_]*)=(.*)$/gm;
const result = [...str.matchAll(regex)];

python

import re
pattern = re.compile(r'^([A-Z_][A-Z0-9_]*)=(.*)$', re.MULTILINE)
result = pattern.findall(text)

go

import "regexp"
re := regexp.MustCompile(`(?m)^([A-Z_][A-Z0-9_]*)=(.*)$`)
result := re.FindAllString(text, -1)
envconfigdevops