I want to implement wild card query in solr. I want that when I search for query= ****diamond
, it should search for whiltediamond etc. ie all '*'
should be replaced by ''
(blank) except 1 *
ie. it should r开发者_如何学运维un as *diamond
, I am using
query=query.replace(/[^a-zA-Z 0-9 * ? : .]+/g,'');
It means other than *
, ?
, :
, .
it is replacing all special characters by a ''. now i want to convert it as that it should replace all *
leaving one *
by ''
.
Than what should be regular expression.
Your regex should do the following:
Replace any number of asterisks by only one asterisk:
query=query.replace(/\*+/,'*');
精彩评论