firasdib / Regex101

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

PCRE2 (?xx) modifier: should not match newline literal in character class #2133

Closed OnlineCop closed 10 months ago

OnlineCop commented 10 months ago

Bug Description

Enabling (?xx) and then using a multi-line character class (as in, contains one or more literal newlines) should not match a literal newline in TEST STRING:

/(?xx)abc[\t
]def/gm

Reproduction steps

Lines 11-12 on https://regex101.com/r/HB1v58/1 contain the text "abc" followed by a newline, followed by "def".

The EXPLANATION on the side also omits mention of the newline; it includes only that the tab should match:

Match a single character present in the list below [\t 
                                                   ]
\t matches a tab character (ASCII 9)

Expected Outcome

Since "extra extended" mode is enabled, only the 2-character \t should be considered, and not the literal newline found within the character class.

In other words, lines 11-12 should not match.

Browser and OS

Vivaldi (Chromium) | 6.1.3035.302 (Stable channel) (64-bit)
Revision | 773772e7e92bf14ad0c8f85f41e3d133d0a2b876
OS | Windows 10 Version 22H2 (Build 19045.3208)
JavaScript | V8 11.4.183.29
User Agent | Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36
firasdib commented 10 months ago

Thanks, fixed locally