Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 383
  • Last Modified:

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

Using JavaScript, how can I remove all words with four or less characters?
0
hankknight
Asked:
hankknight
1 Solution
 
kivan24Commented:
<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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now