RegexTester.dev Logo

Regex Tester & Validator

a(a|b)*a|b(a|b)*b|a|bStarts and ends with the same characterClassic ProblemsFormal RE✨ Emoji Combos

Length-1 strings trivially satisfy this. For length ≥ 2, the first and last characters must match.

✓ Accepts
abaabbababababba
✗ Rejects
abbaaabbbaε
Loading editor…