RU beehive logo ITEC dept promo banner
ITEC 325
2011spring
ibarland

homelectsexamshws
breeze (snow day)

error-checking-misc
input validation
functions; miscellania

PHP regular expressions

PHP regular-expression matching: Regular expressions a strings delimited by a special character (usually /). Some very quick examples: regexp-match-quick-example.php
      echo preg_match( '/row/', 'How now, brown cow?' );
      echo preg_match( '/r.w/', 'How now, brown cow?' );
      echo preg_match( '/n[oe]w/', 'How now, brown cow?' );
      echo preg_match( '/rows?/', 'How now, brown cow?' );
      echo preg_match_all( '/ow/', 'How now, brown cow?' );
      echo preg_match_all( '/rows?/', '\"How now, brown cow?\", he crows.' );

      echo preg_match( '/[0-9]*/', '00047' );
      echo preg_match( '/\\d*/',   '00047' );
      echo preg_match( '/[0-9]+/', '00047' );
    
See the manual.

Atomic regexps

Compound regexps

There are also ways of building bigger regexps out of smaller ones: Three helpful functions:

homelectsexamshws
breeze (snow day)


©2010, Ian Barland, Radford University
Last modified 2011.Feb.11 (Fri)
Please mail any suggestions
(incl. typos, broken links)
to iba�rlandrad�ford.edu
Powered by PLT Scheme