I have a long paragraph which contains almost 2000 words.

I want to extract all those words or group of words which are in single quote e.g.

In the below sentence, I want to extract 1. is 2. important and 3. topic

This 'is' very 'important' 'topic' to discuss

Any body have any idea how to do this in javascript.

There are many ways to do it. You can use regular expression etc. Simplest way is to use loop. For eg

function test() {
var str = "This \'is\' very \'important\' \'topic\' to discuss";
	for (var i=0; i<str.length && str.indexOf('\'') > -1 ; i++){
		startNamePos=str.indexOf('\'')+1;
	 	endNamePos=str.indexOf('\'',startNamePos);
	 	alert(str.substring(startNamePos,endNamePos));
	 	str = str.replace(str.substring(str.indexOf('\''),str.indexOf('\'',startNamePos)+1),"");
	 	i= endNamePos;
	}
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.