Opened 16 years ago
Closed 16 years ago
#1464 closed Bug (Fixed)
StringRegExp, Single Char. Pattern with '*' Quantifier.
| Reported by: | anonymous | Owned by: | Jon |
|---|---|---|---|
| Milestone: | 3.3.5.4 | Component: | AutoIt |
| Version: | 3.3.4.0 | Severity: | None |
| Keywords: | StringRegExpReplace StringRegExp | Cc: |
Description
Well, It took we a wile to be sure.
But I think the following data shows that AutoIt is outputting a wrong(incomplete) RE-result.
Used string 'abbabb'
Used RegExp 'a?' or 'a*' (Problem seems limited to a single character capture pattern with a '*' or '?' quantifier)
Used Replace '*'
Compared against:
TRC=The Regex Coach.exe
RT=www.regextester.com
setting: (Global) Global On Global On Global Off Global Off source: AutoIt RT-Repl TRC-Repl RT-Repl TRC-Repl result: **bbabb **b*b**b*b* **b*b**b*b* *bbabb *bbabb 'a??' or 'a*?' result: ***bbabb ***b*b***b*b* *a*b*b*a*b*b* *abbabb *abbabb
The think the problem is shown in that:
1) AutoIt seems to be using globalReplace mode, indicated by the leading '*' replacements.
- They match up with the others when they are in GlobalReplace mode.
2) AutoIt is not showing the other '*' replacements that are present in the others.
Both StringRegExpReplace() and StringRegExp() are consistent and identical in there behavior.
In this case AutoIt seems to consistently stop when a failed matched is encountered. (so using 'b*' or '[a]*' will fail at the start of the string)
ConsoleWrite('Out1 = ' & StringRegExpReplace('abbabb','a*','*') & @CRLF) ; fail. '**bbabb'
ConsoleWrite('Out2 = ' & StringRegExpReplace('abbabb','b*a','*') & @CRLF) ;; ok. '**bb'
ConsoleWrite('Out3 = ' & StringRegExpReplace('abbabb','b*','*') & @CRLF) ;; fail. '*abbabb'
ConsoleWrite('Out4 = ' & StringRegExpReplace('abbabb','b*b','*') & @CRLF) ;; ok. 'a*a*'
(3.3.4.0)&(3.3.5.3),Environment(Language:0409 Keyboard:00000409 OS:WIN_XP/Service Pack 3 CPU:X86 OS:X86)
Attachments (1)
Change History (7)
comment:1 by , 16 years ago
comment:2 by , 16 years ago
Pcretest is giving a different output then autoit itself.
Its producing the expected correct output.
Base on pcretest.zip test run.
PCRE version 8.00 2009-10-19
string='abbabb'
RE /a*/ /a*b/ /b*/ /b*a/ -NoneGlobal- match a ab * a RE /a*/G /a*b/G /b*/G /b*a/G -Global- match a**a*** abbabb *bb*bb* abba (* = empty match)
comment:3 by , 16 years ago
PS: Never used UTF, so I did not test with that with this prcetest.
Yes, all AutoIt strings are UTF16-LE internally and we have to convert back and forth to UTF8 for the pcre engine. It gets real interesting when trying to deal will character positions. By interesting I mean ball breaking.
comment:4 by , 16 years ago
Try this test version:
http://www.autoitscript.com/forum/index.php?showtopic=109593&view=findpost&p=772804
comment:5 by , 16 years ago
I have checked a additional number of RegExpressions, and so far I only got positive results. (And, Sorry again for my mixup. Hate it when I make that kind of mistake)
comment:6 by , 16 years ago
| Milestone: | → 3.3.5.4 |
|---|---|
| Owner: | set to |
| Resolution: | → Fixed |
| Status: | new → closed |
Fixed by revision [5698] in version: 3.3.5.4

Does pcretest.exe give the same results. What was entered in pcretest?