Regex to determine a Haiku?
Posted: Mon Apr 09, 2007 12:44 am
Anyone know how to tell if a variable is a Haiku using a regular expression with the assumption that <br /> was used to seperate each line?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
The question is in which language? For a language where each vowel builds a syllable, the solution is pretty straightforwardalvinphp wrote:Anyone know how to tell if a variable is a Haiku using a regular expression with the assumption that <br /> was used to seperate each line?
Code: Select all
$text = "
Furu ike ya
kawazu tobikomu
mizu no oto
";
$v = 'aeiou';
$haiku = "/
^
[^$v]*
([$v][^$v]*){5}
\n
[^$v]*
([$v][^$v]*){7}
\n
[^$v]*
([$v][^$v]*){5}
$
/x";
if(preg_match($haiku, $text))
print "ok";
else
print "NOT OK";