I agree that this is confusing, and I think many resources describing regex in 
unhelpful ways is partly to blame.
descriptions like "pattern that matches against a string" and similar.

this implies that a regex has to match the string, but this is not the case.
a regex does not have to match the string, instead the string has to satisfy 
the regex.

"aaa" satisfies /a{,2}/ because it contains everything the regex requires.
thinking of regex in this way has been a help to me atleast 😊

-L

-------- Original Message --------
On 22. jan. 2024, 13:23, Jorge Almeida wrote:

> Please help me to understand this:
> $ perl -e 'exit(10) if "aaa"=~/a{,2}/;'
> $ echo $?
> $ 10
>
> Thanks
>
> Jorge Almeida

Reply via email to