我有这个文本:nisi non text600 elit 其中 600 是动态添加的。我怎样才能得到它?
var str = ('nisi non text600 elit').match(/text\d+/);
alert(str);
这会提醒 text600,我如何才能只提醒 600 而无需额外替换单词 text(如果可能的话)?
感谢任何帮助,谢谢!
最佳答案
var str = ('nisi non text600 elit').match(/text(\d+)/);
alert(str[1]);
关于JavaScript(正则表达式): excluding matches from output,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10701367/