MatchGroupExample1.php

Go to the documentation of this file.
00001 <?php
00002 /* 
00003  * Examples using the match.
00004  *
00005  * @package Match
00006  */
00007 
00008 require_once( "_start.php" );
00009 
00010 function MatchExample1()
00011 {
00012     $objMatch = new MatchGroup();
00013     $objMatch->addItemName( "Flatline" );
00014     $objMatch->addItemName( "Matrix" );
00015     $objMatch->addItemName( "Wintermute" , "artificial" );
00016     $objMatch->addItemName( "Case" , "hacker" );
00017     $objMatch->addItemRegularExpression( "M(.*)y" );
00018     $objMatch->addItemRegularExpression( "A(.*)e" );
00019     $objMatch->addItemRegularExpression( "Winter(.*)" , "machine" );
00020     $objMatch->addItemRegularExpression( "^Case$" , "cowboy" );
00021 
00022         if ( $objMatch->found( "Molly" ) !== true ) return false;
00023         if ( $objMatch->match( "Molly" ) !== true ) return false;
00024         if ( $objMatch->match( "Wintermute" ) !== "artificial" ) return false;
00025         if ( $objMatch->match( "Wintertime" ) !== "machine" ) return false;
00026         if ( $objMatch->match( "Case" ) !== "hacker" ) return false;
00027         if ( $objMatch->match( "Jackson" ) !== false ) return false;
00028         return true;
00029 }
00030 
00031 if( MatchExample1() === TRUE )
00032 {
00033         print "ok!";
00034 }
00035 else
00036 {
00037         print "fail!";
00038 }
00039 ?>

Generated on Sat Apr 7 14:19:09 2012 for CodeToDiagram by  doxygen 1.5.9