...

View Full Version : Resolved Regular expression detect words 4 or fewer letters



gusblake
12-08-2009, 09:50 PM
Hi,
can anyone tell me how to detect any word (a-z only, surrounded by whitespace) less than 5 letters long?

Edit - this is what I have currently:


var RE=/\s([a-z]{1,4})\s/gi;
var string="some words"; //should be turned to "words"
string=string.replace(RE, "");


This is taking 4 letter chunks from the end of words.

Cheers,
Gus

Edit - fixed (replaced \s with \b)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum