HTTP Status Code in JS
Match 3-digit HTTP status codes in the 1xx–5xx range.
Try it in the JS tester →Pattern
regexJS
\b[1-5]\d{2}\b (flags: g)JavaScript / ECMAScript code
jsJavaScript
const re = new RegExp("\\b[1-5]\\d{2}\\b", "g");
const input = "HTTP 200 OK";
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
Leading digit 1–5 covers all standard class codes (informational, success, redirect, client error, server error), followed by any two digits. Word boundaries prevent partial matches.
Examples
Input
HTTP 200 OKMatches
200
Input
Returned 404, then 500Matches
404500
Input
no codes hereNo match
—