Regex for letters only

Use /^[A-Za-z]+$/ to check that a whole string is for letters only. Every example below is tested against the pattern, and you can open it in the Regex Tester with the samples preloaded.

Updated

InputResult
Hello✓ Match
abc✓ Match
XYZ✓ Match
Hello World✗ No match
abc123✗ No match
café✗ No match

How the pattern works

PartMeaning
^[A-Za-z]+$One or more ASCII letters and nothing else

Code examples

JavaScript

const re = /^[A-Za-z]+$/;
re.test(value); // true or false

Python

import re

bool(re.fullmatch(r'[A-Za-z]+', value))

PHP

preg_match('/^[A-Za-z]+$/', $value) === 1;

Notes and limitations

Accented and non-Latin letters (é, ñ, ü, Ж) are rejected. For letters in any language use ^\p{L}+$ with the u flag in JavaScript.

Regex TesterType a pattern and watch matches highlight live in your test text.
Open the tool

Frequently asked questions

What is the regex for letters only?
/^[A-Za-z]+$/ — it matches the whole string. See the table above for what each part does.
Which examples match?
Of the examples tested, these match: Hello, abc, XYZ. The others don’t.
How do I test this regex?
Click “Open in Regex Tester” — the pattern, flags and sample text load automatically, and matches highlight as you edit.