本文介绍了Jquery正则表达式syntex错误无需重复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我使用下面的代码:



$ .extend($ .ui.autocomplete.prototype,{

_renderItem:function(ul,item){

var term = this.element.val(),

term = new RegExp(term,i ),

html = item.label.replace(term, $& );

// alert(term);

返回$(



  • .data(item.autocomplete,item)

    .append ($()。html(html))

    .appendTo(ul);

    }

    });



    对于它运行良好的任何类型的字符串。但是当我键入c ++然后它显示错误。错误是:

    语法错误:无需重复



    请帮助我



    我尝试过什么:



    i使用此代码

    term = new RegExp('/ [^ \\\] gi'+ term,i),

    但它不起作用

    解决方案




    hi
    I use this code below:

    $.extend( $.ui.autocomplete.prototype, {
    _renderItem: function( ul, item ) {
    var term = this.element.val(),
    term = new RegExp(term, "i" ),
    html = item.label.replace( term, "$&" );
    //alert(term);
    return $( "

  • " )
    .data( "item.autocomplete", item )
    .append( $("").html(html) )
    .appendTo( ul );
    }
    });

    for any type of string it works well.but when i type "c++" then it show the error.the error is:
    SyntaxError: nothing to repeat

    plz help me

    What I have tried:

    i have use this code
    term = new RegExp('/[^\w\s]/gi'+term, "i" ),
    but it do not work

    解决方案




    这篇关于Jquery正则表达式syntex错误无需重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    10-27 03:37