---
title: "Discussion on \"A Nested Quantifier Made My Regex Take Seconds on a 30-Character String\" | Hashnode"
description: "Discussion on \"A Nested Quantifier Made My Regex Take Seconds on a 30-Character String\". I was validating a field that should only contain the letter a. Simple job. I wrote this:\nimport re\npat = re.compile(r'^(a+)+$')\n\nIt looked fine. It matched aaa. It matched thirty a's in a blink. Then"
url: "https://hashnode.com/posts/a-nested-quantifier-made-my-regex-take-seconds-on-a-30-character-string/6af55ef1ab4ca5f49f2ce02f"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [A Nested Quantifier Made My Regex Take Seconds on a 30-Character String](https://aheadkit.hashnode.dev/a-nested-quantifier-made-my-regex-take-seconds-on-a-30-character-string?utm_source=hashnode&utm_medium=feed)

I was validating a field that should only contain the letter a. Simple job. I wrote this: import re pat = re.compile(r'^(a+)+$') It looked fine. It matched aaa. It matched thirty a's in a blink. Then

6h ago · 5 min read · aheadkit.hashnode.dev  
Read the article

-   [#python](https://hashnode.com/tag/python)
-   [#regex](https://hashnode.com/tag/regex)
-   [#programming](https://hashnode.com/tag/programming)
-   [#debugging](https://hashnode.com/tag/debugging)

## Written by

[Abdus Salam](https://hashnode.com/@aheadkit)

@aheadkit

  
[View profile](https://hashnode.com/@aheadkit)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
