-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.php
72 lines (51 loc) · 1.62 KB
/
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
require __DIR__ . "/vendor/autoload.php";
use Maestroerror\EloquentRegex\Builder;
$input = "Passs1234";
$builder = new Builder($input);
// Min 8 chars, min 1 uppercase
$check = $builder->textOrNumbers(8, 0, 1)->check(); // Exact same (entire input from start ^ to end $)
print_r($check);
echo "\n";
$string = "asd Passs1234 wawd";
$builder = new Builder($string);
// Min 8 chars, min 1 uppercase
$check = $builder->textOrNumbers([
"minLength" => 8,
"minUppercase" => 1
])->checkString(); // Includes min 1
print_r($check);
echo "\n";
$string = "asd Passs1234 Wawoline343 text here";
$builder = new Builder($string);
$count = $builder->textOrNumbers(function($query) {
return $query->minLength(8)->minUppercase(1);
})->count(); // Returns number of matches
print_r("Count: " . $count);
echo "\n";
$string = "Passs1234 an 1sada a 5464565";
$builder = (new Builder($string))->textOrNumbers(4);
$get = $builder->get();
print_r($get);
echo "\n";
$regex = $builder->toRegex();
print_r($regex);
echo "\n";
// $string = "Passs1234 an 1sada a 5464565";
// $builder = (new Builder($string))->textOrNumbers("string")->check();
$SR = new Builder("RI-214");
$check = $SR->start()->textUppercase(2)->dash()->digits()->end()->check();
print_r($check); // true
echo "\n";
$SR = new Builder("RI-2142");
$check = $SR->pattern(function ($builder) {
return $builder->textUppercase(2)->dash()->digits(3);
})->check();
print_r($check); // false
echo "\n";
$SR = new Builder("RI-214 - A nice task");
$get = $SR->pattern(function ($builder) {
return $builder->textUppercase(2)->dash()->digits(3);
})->get();
print_r($get); //
echo "\n";