Regular Expressions << Metacharacters >> Character Classes
Metacharacters are special add-on things for doing a search. Keeping the z as our example to search for, here is a list of different metacharacters you can use...

^zsearches for a part that begins with z.
z$searches for a part that ends with z.
z+searches for at least one z in a row.
z?searches for zero or one z.
(yz)searches for yz grouped together.
y|zsearches for y or z.
z{3}searches for zzz.
z{1,}searches for z or zz or zzz and so on...
z{1,3}searches for z or zz or zzz only.

Other metacharacter type searches include...

.searches for ANY character or letter.
[a-z]searches for any lowercase letter.
[A-Z]searches for any uppercase letter.
[0-9]searches for any digit 0 to 9.
\escapes the next character.
\nnew line.

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 ( 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.

$value1 = "";
$value2 = "";
$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.";}

Fatal error: Uncaught Error: Call to undefined function eregi() in /misc/40/000/085/738/8/user/web/ Stack trace: #0 {main} thrown in /misc/40/000/085/738/8/user/web/ on line 76