Environment Variable Reference
beginnerMatches environment variable references in various formats.
envvariableshelldevelopment
Pattern
/(?:\$\{([A-Z_][A-Z0-9_]*)\}|\$([A-Z_][A-Z0-9_]*)\b|process\.env\.([A-Z_][A-Z0-9_]*))/gTry It
0 of 6 strings matched
Explanation
Matches environment variable references in three formats: ${VAR}, $VAR, or process.env.VAR. Variable names must start with a letter or underscore and contain uppercase letters, digits, and underscores.
Test Strings
Matching
- ${DATABASE_URL}
- $HOME
- process.env.NODE_ENV
Non-matching
- $lowercase
- ${123}
- env.VAR
Language Compatibility
| Language | Support |
|---|---|
| JS | Full support |
| PYTHON | Full support |
| JAVA | Full support |
| PHP | Full support |
| GO | Full support |
Code Snippets
const regex = /(?:\$\{([A-Z_][A-Z0-9_]*)\}|\$([A-Z_][A-Z0-9_]*)\b|process\.env\.([A-Z_][A-Z0-9_]*))/g;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);