Solved

JavaScript/Regex: Remove all words with four or less characters

Posted on 2011-03-03
1
377 Views
Last Modified: 2012-05-11
Using JavaScript, how can I remove all words with four or less characters?
0
Comment
Question by:hankknight
1 Comment
 
LVL 8

Accepted Solution

by:
kivan24 earned 500 total points
ID: 35027253
<script language="JavaScript">
var str='Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean aliquet leo eu nisl egestas vulputate.';
document.write(str);
document.write("<hr>");
var result = str.replace(/\b\s*\w{1,4}\b/g, "");
document.write(result);
</script>

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question