Gossamer Forum
Home : General : Perl Programming :

at least 3 words

Quote Reply
at least 3 words
Is this the reg. exp. for at least 3 words?

Code:
'.\s{3,}'
Quote Reply
Re: at least 3 words In reply to
Im not sure, but i thought: '[\s]{3,}'
Quote Reply
Re: at least 3 words In reply to
Well, not really. What that matches is any character followed by a space three or more times. Since a space is any character, it counts those as well.

Try:

m/(\b\w+\b){3,}/

which I think should do the trick. It says match a word boundry, followed by one or more letters/numbers, followed by another word boundary.

Hope that helps,

Alex