var myVar= $("[class*=TextType]").attr("class")
//myVar returns Textabc Textxyz TextTypeTestingText
//I want to get TextTypeTestingText from myVar
var FinalWord = myVar.match(/TextType+/g)
alert(FinalWord)
这只会提醒TextType,但不会提醒我正在寻找的整个单词
答案 0 :(得分:0)
您只需要匹配字母,而不是重复最后一个字符(在您的情况下为e
)。
'Textabc Textxyz TextTypeTestingText'.match(/TextType\w*/)[0]; // TextTypeTestingText
如果您还想匹配其他非空格字符,可以使用/TextType\S+/
。