You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Didn't it cover all your needs? Let's take a look to the custom patterns section.
179
+
180
+
## Custom Patterns
181
+
182
+
For scenarios where predefined patterns do not suffice, EloquentRegex allows you to define custom patterns using the start or customPattern methods as initiator:
183
+
184
+
```php
185
+
EloquentRegex::start($yourString);
186
+
// Or
187
+
EloquentRegex::customPattern($yourString);
188
+
```
189
+
190
+
_Note: They does the exaclty same thing, you can use your favorite one_
191
+
192
+
### Creating a Custom Pattern
193
+
194
+
You can start building a custom pattern to match a specific string format, such as a custom ID format that starts with letters followed by digits:
195
+
196
+
```php
197
+
$result = EloquentRegex::start('ID123456')
198
+
->literal('ID')
199
+
->digitsRange(1, 10)
200
+
->check();
201
+
202
+
if ($result) {
203
+
echo "The string matches the custom ID format!";
204
+
} else {
205
+
echo "The string does not match the custom ID format.";
206
+
}
207
+
208
+
```
209
+
210
+
Custom pattern builder supports a wide range of character classes and all special chars. Also, `literal` or `exact` method could be used to match exact string you need, or `char` method could be used to match exact character. The full list of pattern builder methods is comming soon. Before that, you can check this files out:
0 commit comments