indefinite-article.js icon indicating copy to clipboard operation
indefinite-article.js copied to clipboard

Regex not anchored

Open lesliev opened this issue 1 year ago • 0 comments

This regex is not anchored:

    if (word.match(/(?!FJO|[HLMNS]Y.|RY[EO]|SQU|(F[LR]?|[HL]|MN?|N|RH?|S[CHKLMNPTVW]?|X(YL)?)[AEIOU])[FHLMNRSX][A-Z]/)) {
        return "an";
    }

It looks to me like this was intended:

    if (word.match(/^(?!FJO|[HLMNS]Y.|RY[EO]|SQU|(F[LR]?|[HL]|MN?|N|RH?|S[CHKLMNPTVW]?|X(YL)?)[AEIOU])[FHLMNRSX][A-Z]/)) {
        return "an";
    }

As it is, this matches "SR" in "GDSR applicant" and returns "an" for "an GDSR applicant".

lesliev avatar Oct 05 '23 04:10 lesliev