Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Regular Coder
    Join Date
    Jan 2006
    Posts
    568
    Thanks
    6
    Thanked 84 Times in 84 Posts

    Regular expression detect words 4 or fewer letters

    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:

    Code:
    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)
    Last edited by gusblake; 12-08-2009 at 11:44 PM.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •