-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
28 lines (24 loc) · 846 Bytes
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php declare(strict_types=1);
include 'vendor/autoload.php';
?>
<h1>SwitchCat/range-regex</h1>
<?php
use \SwitchCat\RangeRegex\FactoryDefault;
use \SwitchCat\RangeRegex\Range;
if(isset($_POST))
{
if(isset($_POST['min']) && isset($_POST['max']))
{
$Factory = new FactoryDefault();
$converter = $Factory->getConverter();
$Range = new Range((int)$_POST['min'], (int)$_POST['max']);
$regex = sprintf('/^(%s)$/', $converter->toRegex($Range));
echo '<h3>Regex capturing numbers from ' . $_POST['min'] . ' to ' . $_POST['max'] . ': ' . $regex . '</h3>';
}
}
?>
<form method="post" name="regex" action="">
<label for="min">Start:</label><input type="number" name="min">
<label for="max">Stop:</label><input type="number" name="max">
<input type="submit" value="Generate regex">
</form>