Regex for Checking for at Least One Uppercase Letter

Tests whether a string contains at least one uppercase letter anywhere.

Published October 11, 2026

A lookahead lets you require an uppercase letter anywhere in the string without consuming characters.

How the pattern works

Breaking the pattern down: (?= = positive lookahead; .*[A-Z] = anything then an uppercase letter.

Test your regex against both matching and non-matching inputs; use the Regex tool on this site to experiment live.

Pattern tests

/(?=.*[A-Z])/
✓ 'hello World'
✓ 'ABC'
✗ 'hello'
✗ '123'

Practical examples

The pattern

const re = /(?=.*[A-Z])/

Test it

const re = /(?=.*[A-Z])/
re.test('hello World')   // true
re.test('ABC')   // true
re.test('hello')   // false
re.test('123')   // false

In Python

import re
re.search(r'(?=.*[A-Z])', text)

Common mistakes

  • Putting it in a pattern without anchors for the rest.
  • Forgetting multi-line mode.
  • Expecting it to match characters (it is zero-width).

Key takeaways

  • Anchors (^ and $) make the whole string match instead of a part of it.
  • Regex checks format only; verify data separately when it matters.
  • Test with valid and invalid samples.

FAQ

Why a lookahead?

It checks a condition without consuming text, so conditions can be combined.

Where can I test this pattern?

Use the Regex Tester on this site, or regex101.com.

More General articles