if you are  looking for the regex only solution, then you may try this

$word =~ /^((un|in).{3}|non.{2})$/

 


________________________________
 From: Binish A.R <[email protected]>
To: "[email protected]" <[email protected]>; "[email protected]" 
<[email protected]> 
Sent: Sunday, April 8, 2012 6:19 PM
Subject: Re: regex
 
Why don't you check the length of the string as well .. ie

if (length($word) ==  5 && $word =~ /^(un|in|non).+$/) {
 ## Do something
}
 


________________________________
From: Somu <[email protected]>
To: [email protected] 
Sent: Sunday, April 8, 2012 4:30 PM
Subject: regex

Hello everyone...
Thanks for the previous replies. I'm really improving!
A new problem..

Check if the word begins with un or in and has exactly 5 letters.
$word =~ '^(un|in).{3}$'

Check if the word begins with un or in or non and has more than 5 letters.


$word =~ '^(un|in).{3}.+$'

What do i do about the words starting with "non" because it has one more
letter than un or in

-- 
Love,
Somu,

Reply via email to