Reputation: 64014
How do you create a perl regex that matches the following conditions?
. - " ,
)So words like "barbar..", "bar.", "ba.." should be rejected in matching.
Upvotes: 1
Views: 1730
Reputation: 2247
Instead of alphabets, if you want to allow alphanumeric you can use this /^\w{5,}$/
(It will also match '_')
\w normally matches alphanumeric in ASCII. For some of the exceptions, see the answer by Sinan in this post How can I validate input to my Perl CGI script so I can safely pass it to the shell?
Upvotes: 0
Reputation: 9016
I would take Nightfirecat's answer and add word boundaries to it to catch words - his is for an entire string.
/\b[a-zA-Z]{5,}\b/
Upvotes: 1
Reputation: 11610
Do you mean for a word to be longer than 4 characters, and only to contain alpha-characters?
This will match 5 or more letters from a-z, non-case-sensitive:
/^[a-zA-Z]{5,}$/
Upvotes: 6