develooper Front page | perl.beginners | Postings from April 2012

Re: regex

Thread Previous | Thread Next
From:
Binish A.R
Date:
April 8, 2012 05:49
Subject:
Re: regex
Message ID:
1333889350.25092.YahooMailNeo@web31812.mail.mud.yahoo.com
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 <som.ctc@gmail.com>
To: beginners@perl.org 
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,

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About