Learn AspNet Learn AspNet - 1 year ago 53
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)

alert(FinalWord)


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

Answer Source

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+/.