[TIMOB-818] Regular expression with case insensitive modifer (/i) behaves strangely
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Trivial |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-04-17T01:54:20.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | iOS |
Labels | expression, javascript, match, mobilesdk, regex, regular, search |
Reporter | Nick Wing |
Assignee | Reggie Seagraves |
Created | 2011-04-15T02:37:07.000+0000 |
Updated | 2011-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)
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.