| Home > Computer & I'net > Metacharacters... |
Metacharacters | |||||||||||||||||||||||||||||||||||||||||
Other metacharacter type searches include...
The escape is used if you want to include a special character in the search itself. These are ^.[]$()|*?{}. Since these characters in used as search commands, if you need to search for that character itself, you need to put the escape in front of it. For example... if you need to search for a dollar sign, it would look like $ instead of just the dollar sign. The dollar sign by itself would create a search that ends with something. These search parameters can be used alone or in combinations. A real world example would be to look at an email address and check to see if it seems to be valid or not. A seemingly valid email address (someone@someplace.com) contains : 1. An unknown amount of letters or numbers. .+ 2. The @ symbol. @ 3. An unknown amount of letters or numbers. .+ 4. A period.. (Remembering to escape it.) 5. Some ending characters. .+ This will not actually check to see if the email itself is a working one, but at least it will check to see if it qualifies to be an email address to begin with. <?php $value1 = "here@there.com"; $value2 = "here@there.ca"; $value3 = "here@therecom"; $search_pattern = ".+@.+..+"; $result1 = eregi($search_pattern,$value1); $result2 = eregi($search_pattern,$value2); $result3 = eregi($search_pattern,$value3); if ($result1) {echo "one is true. ";} else {echo "one is false. ";} if ($result2) {echo "two is true. ";} else {echo "two is false. ";} if ($result3) {echo "three is true.";} else {echo "three is false.";} ?> one is true. two is true. three is false. Using these metacharacters and a pair of (parentheses) you can create a number of different and complex search patterns. Here are some examples of different search patterns :
----------------- 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 |
|