0

I've learned about regular expressions recently. So far I had no problems with understanding, but there is one case which confuses me:

.+[123]

If I understand it correctly, in this case expression ".+" should iterate through every character until one of this characters appears [123]. However in cases like this:

abc abc abc 21 efg efg 2344

It matches "abc abc abc 21 efg efg 23" ignoring 2,1,2.

Why does it happen? (I use regex101.com for checking)

I used search in order to find something, but I didn't find anything about this case. I made a workaround [^123]+[123], but I want to understand why this happens.

Avtem
  • 45
  • 1
  • 8

0 Answers0