#3631 closed Bug (No Bug)
StringRegExp - metacharacter "\R" in square brackets behaves incorrectly
| Reported by: | Owned by: | ||
|---|---|---|---|
| Milestone: | Component: | AutoIt | |
| Version: | 3.3.14.0 | Severity: | None |
| Keywords: | Cc: |
Description
Metacharacter "\R" in square brackets behaves incorrectly
#include <Array.au3> $sText = @CRLF & _ 'Left' & @CRLF & _ 'Right' & @CRLF & _ 'ringtone' & @CRLF StringRegExp($sText, '(.+)[\R]', 3) If @error Then MsgBox(16, @ScriptLineNumber, 'Why a @error?') MsgBox(32, @ScriptLineNumber, _ 'where the letter "R":' & @CRLF & _ StringRegExpReplace($sText, '[\R](.+)', '$1'))
Attachments (0)
Change History (3)
follow-up: 2 comment:1 by , 8 years ago
| Resolution: | → No Bug |
|---|---|
| Status: | new → closed |
comment:2 by , 8 years ago
Replying to jchd18:
As the helpfile says \R is not special in a character class.
I need to fix you, but in the help file (in the description of [...]) the following is said:
"Note that in a character class, only \d, \D, \h, \H, \p{}, \P{}, \s, \Q...\E, \S, \v, \V, \w, \W, and \x sequences retain their special meaning, while \b means the backspace character (Chr(8))".
And unfortunately I didn't realize it right away. I apologize.
comment:3 by , 8 years ago
I know what the help says because yours truly authored this topic. Saying "only this and that work" is equivalent (and shorter in our case) to saying that anything not listed doesn't.

As the helpfile says \R is not special in a character class. Therefore [\R] is the same as [R] and hence the same as R
@error set to 1 means no match occured. It's clear when you look closely to the meaning of your pattern.
Please refrain to post a bug report before asking in the Help forum first.