Last active
October 6, 2015 06:38
-
-
Save VaclavSir/2952497 to your computer and use it in GitHub Desktop.
PHP PCRE Tester
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header('content-type: text/html; charset=utf-8'); | |
$pattern = isset($_POST['pattern']) ? $_POST['pattern'] : '~^$~'; | |
$subject = isset($_POST['subject']) ? $_POST['subject']: ''; | |
?> | |
<h1>Preg_match tester</h1> | |
<form method="post"> | |
<p>Pattern:<br><textarea name="pattern" cols="80" rows="4"><?php echo htmlspecialchars($pattern) ?></textarea></p> | |
<p>Subject:<br><textarea name="subject" cols="80" rows="4"><?php echo htmlspecialchars($subject) ?></textarea></p> | |
<p><input type="submit" value="Test"></p> | |
</form> | |
<?php | |
$result = preg_match($pattern, $subject, $matches); | |
?> | |
<h2>Result</h2> | |
<?php var_dump($result) ?> | |
<h2>Matches</h2> | |
<?php var_dump($matches) ?> | |
<h2>Input</h2> | |
<table border="1"> | |
<tr> | |
<th>Pattern: </th> | |
<td><pre><?php echo htmlspecialchars($pattern) ?></pre></td> | |
</tr> | |
<tr> | |
<th>Subject: </th> | |
<td><pre><?php echo htmlspecialchars($subject) ?></pre></td> | |
</tr> | |
</table> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment