| Home > Computer & I'net > Regular Expressions... |
Regular Expressions | |
A pattern is what you are looking for in a specific area. It can be a word, a letter, whatever. For our examples, we will use the letter z. There are two commands to use for searching. ereg for doing a case sensitive search (for specifically a lower or upper case letter) or eregi for doing a case insenitive search (searching for either a lower or upper case letter). The ereg command takes two properties. One for the pattern to search for, the second for the search area. ereg <?php result :
$pattern = "z"; $search_area = "My car goes ZOOM."; $search_result = ereg($pattern,$search_area); if ($search_result){ // print this if there is a true result. echo "Success, the pattern was found!"; } else { // print this if there is a false result. echo "Failure, the pattern was not found!"; } ?> Failure, the pattern was not found! eregi <?php
$pattern = "z"; $search_area = "My car goes ZOOM."; $search_result = eregi($pattern,$search_area); if ($search_result){ // print this if there is a true result. echo "Success, the pattern was found!"; } else { // print this if there is a false result. echo "Failure, the pattern was not found!"; } ?> result : Success, the pattern was found!
----------------- Article by David Stanley. Visit his site http://www.htmlite.com. Reprinted with permission. | |
| Articles |
•Auto & Trucks•Business•Computer & I'net·General·Apache·CSS·Database·Hardware·HTML·Javascript&DHTML·Linux·MySQL·Operating System·Perl / CGIPHP·Programming·Publishing·Search Engines·Software Problems·SSI·Tips & Tricks·Utilities·Web Design•Family•Food & Drink•Gardening•Health•Other•Pets•Psychology•Spiritual•Travel•Women |
| Calculators |
|