Regex HELP: Why /^(?=.{4,})/g isn't matching "aaaa", "bbbb" and so on?

Hi everyone ! Why /^(?=.{4,})/g isn’t matching “aaaa”, “bbbb” and so on? It would be great if you could explain to me why it isn’t matching these. Thanks in advance.

Hello riyadif.

I think you are misunderstanding the point of the look-ahead expression ?=.

What I think you want is: ^(.{4,})
However, this is a very greedy expression.

What you have technically does match “aaaa”… However, it will match this, and return the beginning of the line (depending on what method you use on the regex).

I suggest you have a look at this lesson on the curriculum:

Hope this helps

I know that ^(.{4,}) matches “aaaa…” but in the below picture (marked by red rectangle) you can see that they used it to match 8 characters and more, similar to what I am trying to do.