Javascript通配符变量? [英] Javascript wildcard variable?
本文介绍了Javascript通配符变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
product_id
的值可能是字母和数字的某种组合,例如:GB47NTQQ。
The value of product_id
might be some combination of letters and numbers, like: GB47NTQQ.
我想要的查看除第3和第4个字符以外的所有字符是否相同。
I want to check to see if all but the 3rd and 4th characters are the same.
类似于:
if product_id = GBxxNTQQ //where x could be any number or letter.
//do things
else
//do other things
如何使用JavaScript实现此目的?
How can I accomplish this with JavaScript?
推荐答案
使用正则表达式和string.match()。期间是单个通配符。
Use regular expression and string.match(). Periods are single wildcard characters.
string.match(/GB..NTQQ/);
这篇关于Javascript通配符变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文