我正在编写动态正则表达式以在自动完成控件中使用它,但我需要支持Internet Explorer。问题,'y'标志不受支持(IE)。 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/sticky
我的示例正则表达式:
/Some text/giy.test('Some')
输出:
Syntax error in regular expression
有人知道填充物吗?
答案 0 :(得分:0)
不是一个正式的正则表达式,但它是一种验证相同的方法:
var reg = 'Some Text';
var search = 'Some';
var isSticky = reg.toLocaleLowerCase().indexOf(search.toLocaleLowerCase()) === 0;
代码可以包装在函数中以进行polyfill