Learn AspNet Learn AspNet - 1 month ago 6x
Javascript Question

Get complete word after matching the pattern in jquery

var myVar= $("[class*=TextType]").attr("class")

//myVar returns Textabc Textxyz TextTypeTestingText
//I want to get TextTypeTestingText from myVar

var FinalWord = myVar.match(/TextType+/g)


This only alerts TextType but not the whole word that I am looking for


You need to match only letters, not to repeat the last character (in your case e).

'Textabc Textxyz TextTypeTestingText'.match(/TextType\w*/)[0]; // TextTypeTestingText

If you want to match other non-space characters too, you can use /TextType\S+/.