ISO 4217 Currency Code in JS
Validate 3-letter ISO 4217 currency codes (USD, EUR, GBP, JPY, etc.) — structural check only.
Try it in the JS tester →Pattern
regexJS
^[A-Z]{3}$JavaScript / ECMAScript code
jsJavaScript
const re = new RegExp("^[A-Z]{3}$", "");
const input = "USD";
const matches = [...input.matchAll(re)];
console.log(matches.map(m => m[0]));Uses `String.prototype.matchAll` for global iteration (Node 12+ / all modern browsers).
How the pattern works
^[A-Z]{3}$ requires exactly three uppercase letters, anchored to the full string. This validates the FORMAT but not the existence of the code — pair with a lookup table to ensure it's a real ISO 4217 entry like USD, EUR, GBP.
Examples
Input
USDMatches
USD
Input
JPYMatches
JPY
Input
usNo match
—