firasdib / Regex101

This repository is currently only used for issue tracking for www.regex101.com
3.2k stars 198 forks source link

The description of the /g parameter is misleading #2191

Open simon-coherent opened 6 months ago

simon-coherent commented 6 months ago

Bug Description

The REGEX FLAG /g is described as "Don't return after first match". This is pretty misleading as the /g flag is "global" representing return all matches.

Reproduction steps

Expected Outcome

"Return matches after the first match" might be a better description and makes more sense when it is checked?

Browser

Include browser name and version

OS

Include OS name and version

OnlineCop commented 6 months ago

W3Schools describes the "g" modifier:

The "g" modifier specifies a global match. A global match finds all matches (compared to only the first).

Mozilla MDN describes it this way:

The g flag indicates that the regular expression should be tested against all possible matches in a string.

I might personally word it as "Search globally for all matches" or something else that can be written tersely (since it goes into a small dropdown that needs to be easily readable on handheld devices as well).

The reasoning for this phrasing is to include the word "global" somewhere in the description so it clicks to a user why the letter "g" is used as its flag.

simon-coherent commented 6 months ago

I would counter that the other REGEX FLAGS don't necessarily include the exact same term in their description. I'm sure many permutations of the wording would suffice but certainly the word "don't" should definitely be removed because it's incorrect in the context when the flag is enabled.

image