0

I have a query on ? in RegEx of Javascript. The explanation for this is given as Matches zero or one occurrences. Can you please see the below screenshot from RegExPal and help me explain the functionality?

enter image description here

In the above picture, even though the upper case characters are mentioned, why they are failed to get selected? Now see the below picture, I just swapped the order and I can see the selection. Can you please explain?

enter image description here

METALHEAD
  • 2,734
  • 3
  • 22
  • 37
  • BTW, `/[A-Z]?/g` selects `ABC` [regardless](https://regexr.com/4tb4l) of [position](https://regexr.com/4tb4i). – Wiktor Stribiżew Jan 31 '20 at 09:38
  • ? Quantifier indicates matches between zero and one times, as many times as possible. So position should not matter here. Please use right regex checking tool as your point is right. [Working demo on another REGEX checking site](https://regex101.com/r/dGZwLj/3) – Shweta Jan 31 '20 at 09:49
  • Might be there is a bug in the website I am referring. – METALHEAD Jan 31 '20 at 09:53

0 Answers0