Validation

Alphanumeric Only

Match strings containing only letters (A–Z, a–z) and digits (0–9), with no spaces or special characters.

Try it in RegexPro →

Available in

JavaScript / ECMAScript code

jsJavaScript
const re = new RegExp("^[a-zA-Z0-9]+$", "");
const input = "Hello123";
const matches = [...input.matchAll(re)];
console.log(matches.map(m => m[0]));

Uses `String.prototype.matchAll` for global iteration (Node 12+ / all modern browsers).

Pattern

regexengine-agnostic
^[a-zA-Z0-9]+$

Raw source: ^[a-zA-Z0-9]+$

How it works

^ and $ anchor to the full string. [a-zA-Z0-9]+ requires one or more characters from the combined letter and digit set. Any space, punctuation, or symbol will cause the match to fail.

Examples

Input

Hello123

Matches

  • Hello123

Input

abc

Matches

  • abc

Input

has space

No match

Common use cases

  • Token and code validation (invite codes, promo codes)
  • Search parameter sanitization
  • Identifier format enforcement
  • Anti-injection input filtering

Related patterns