RegEx for Javascript to allow only alphanumeric

前端 未结 18 1436
轻奢々
轻奢々 2020-11-22 15:13

I need to find a reg ex that only allows alphanumeric. So far, everyone I try only works if the string is alphanumeric, meaning contains both a letter and a number. I just w

18条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 15:32

    Input these code to your SCRATCHPAD and see the action.

    var str=String("Blah-Blah1_2,oo0.01&zz%kick").replace(/[^\w-]/ig, '');
    

提交回复
热议问题