Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-818] Regular expression with case insensitive modifer (/i) behaves strangely

GitHub Issuen/a
TypeBug
PriorityTrivial
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:54:20.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsexpression, javascript, match, mobilesdk, regex, regular, search
ReporterNick Wing
AssigneeReggie Seagraves
Created2011-04-15T02:37:07.000+0000
Updated2011-04-17T01:54:20.000+0000

Description

It's not simply being ignored. It seems that expressions with an even number of characters work correctly, while those with an odd length fail to match. Without the /i modifier, all tested expressions have been correct.

var mystring = 'Add to Address Book';
// with /i modifier
Ti.API.info(mystring.search(/s/i)); // -1 (incorrect) (string length: odd)
Ti.API.info(mystring.search(/ss/i)); // 12 (correct) (string length: even)
Ti.API.info(mystring.search(/ess/i)); // -1 (incorrect) (string length: odd)
Ti.API.info(mystring.search(/ress/i)); // 10 (correct) (string length: even)
Ti.API.info(mystring.search(/dress/i)); // -1 (incorrect) (string length: odd)
Ti.API.info(mystring.search(/ddress/i)); // 8 (correct) (string length: even)
Ti.API.info(mystring.search(/address/i)); // -1 (incorrect) (string length: odd)
Ti.API.info(mystring.search(/address /i)); // 7 (correct) (string length: even)
// no modifier
Ti.API.info(mystring.search(/address/)); // -1 (correct) (both cases correct here)
Ti.API.info(mystring.search(/ddress/)); // 8 (correct)

Comments

  1. Stephen Tramer 2011-04-15

    Was actually a duplicate of another bug (with the same sample code!) at some point. I remember fixing it.

    Tested against 1.6.0 RC1, confirmed.

JSON Source