September, 2013

REGEX

. $string1 = "Hello World\n"; if ($string1 =~ m/…../) { print "$string1 has length >= 5\n"; } ( ) $string1 = "Hello World\n"; if ($string1 =~ m/(H..).(o..)/) { print "We matched ‘$1’ and ‘$2’\n"; } Output: We matched ‘Hel’ and ‘o W’; + $string1 = "Hello World\n"; if ($string1 =~ m/l+/) { print "There are one or more consecutive letter \"l\"’s in $string1\n"; } Output: There are one or more consecutive letter "l"’s in Hello World ? $string1 = "Hello World\n"; if ($string1 =~ m/H.?e/) { print "There is an ‘H’ and a ‘e’ separated by "; print "0-1 characters (Ex: He Hoe)\n"; } ? $string1 = "Hello World\n"; if […]

Posted in PHP | Comments Off on REGEX