On 08/04/2012 12:00, Somu wrote:
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

Hi Somu

You should use (?:...) instead of just (...) as the latter wastefully
captures substrings that you are not using.

To match the string you describe you require

  /^(?:un.|in.|non)...+/

Rob


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to