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 2 of 2
  1. #1
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts

    checking a string (sentence) has no more than 25 words.

    Hi,

    I want to restrict the length of a sentence to 25 words as part of the server-side validation.

    Is the better (best paractice), way to do this; to split the sentence into an array and use the 'scalar @array' to determine whether the sentent is too long? I know its a timtowtdi thing but surely one way must be better?

    bazz
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #2
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,910
    Thanks
    2
    Thanked 164 Times in 159 Posts
    It would be more efficient to use the tr operator to count the number of spaces.


  •  

    Posting Permissions

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