#native_company# #native_desc#
#native_cta#

Regular Expressions Testing Tool

By Tom Kredo
on February 16, 2003

Version: 1

Type: Full Script

Category: Other

License: GNU General Public License

Description: Allows you to test the validity of a Regular Expression against a sample string. Great for learning how to use RegEx or to create and test new ones. This program is written in PHP.

<? # Program to test Regular Expressions  by Tom Kredo 2003
# Example Test for valid Zip Code:  String= 14610-1234 Pattern=^([0-9]{5})(-[0-9]{4})?$

$self=$_SERVER['PHP_SELF']; # Get the Global for who we are

if($_POST['pattern']) {
	$pattern=$_POST['pattern'];
	$string=$_POST['string'];
	if (eregi($pattern,$string))
		echo "$pattern pattern matches "$string"";
	else
		echo "$pattern pattern does not match "$string"";
	}
?>
<html>
<body>
<h1>Testing Regular Expressions</h1>
<form action=<? echo "$self"; ?> method=POST>
String: <input type=text name="string" value="<? echo "$string"; ?>" size=30><br><br>
RegEx Pattern: <input type=text name="pattern" value="<? echo "$pattern"; ?>" size=30><br><br>
<input type=submit value="Test Pattern" name="Submit">
</form>
</body></html>