#3631 closed Bug (No Bug)
StringRegExp - metacharacter "\R" in square brackets behaves incorrectly
Reported by: | Alofa <alofa.script@…> | 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)
comment:1 follow-up: ↓ 2 Changed 7 years ago by jchd18
- Resolution set to No Bug
- Status changed from new to closed
comment:2 in reply to: ↑ 1 Changed 7 years ago by Alofa <alofa.script@…>
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 Changed 7 years ago by jchd18
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.
Guidelines for posting comments:
- You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
- In-depth discussions should take place on the forum.
For more information see the full version of the ticket guidelines here.
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.