Modify

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#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 by jchd18, 8 years ago

Resolution: No Bug
Status: newclosed

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.

in reply to:  1 comment:2 by Alofa <alofa.script@…>, 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 jchd18, 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.

Modify Ticket

Action
as closed The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.