Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0005391 [Squeak Packages] VBRegex minor always 11-09-06 14:54 01-06-07 04:08
Reporter anselm View Status public  
Assigned To
Priority normal Resolution open  
Status new  
Summary 0005391: Not commutative
Description Certain regular expressions are not commutative:

'15' matchesRegex: '[1-9]|1[0-9]'. false
'15' matchesRegex: '1[0-9]|[1-9]'. true

Seems that in the first case evaluation stops at the first expression before the '|'. Evaluation with a single character works:

'1' matchesRegex: '[1-9]|1[0-9]'. true
'1' matchesRegex: '1[0-9]|[1-9]'. true
Additional Information Brackets don't make any difference:

'15' matchesRegex: '([1-9])|(1[0-9])'. false
'15' matchesRegex: '(1[0-9])|([1-9])'. true

'1' matchesRegex: '([1-9])|(1[0-9])'. true
'1' matchesRegex: '(1[0-9])|([1-9])'. true
Attached Files

- Relationships

- Notes
(0008842 - 461 - 647 - 647 - 647 - 647 - 647)
nicolas cellier
01-06-07 04:08

Yes, this is a bug in regex...
RxMatcher>>matchesStream: theStream
    "Match thyself against a positionable stream."

    ^(self matchesStreamPrefix: theStream)
        and: [stream atEnd]

15 prefix matches [1-9], so the alternative 1[0-9] is not even checked for...
But the stream is not at end.
So this code is wrong!

Workaround: you can temporarily use an end of line matcher - $ - to obtain a correct behaviour:

'15' matchesRegex: '[1-9]$|1[0-9]'. true
 

- Issue History
Date Modified Username Field Change
11-09-06 14:54 anselm New Issue
01-06-07 04:08 nicolas cellier Note Added: 0008842


Mantis 1.0.8[^]
Copyright © 2000 - 2007 Mantis Group
32 total queries executed.
27 unique queries executed.
Powered by Mantis Bugtracker