Regex Helpers for Laravel/PHP

Poovarasu
1 min readAug 13, 2021

hotmeteor/regex is a set of ready-made regex helper methods for use in your Laravel application

This package comes with common regular expression patterns that are ready to match and replace against values. The package supports case-insensitivity, Unicode characters and supports all languages.

Here are some examples from the package’s readme:

// MatchRegex::isAlpha($subject, $allowWhitespace = false);Regex::isAlphanumeric($subject, $allowWhitespace = false);Regex::isAlphadash($subject, $allowWhitespace = false);Regex::isDigits($subject, $allowWhitespace = false);Regex::isNumeric($subject);// ReplaceRegex::alpha($subject, $replace = '');Regex::alphanumeric($subject, $replace = '');Regex::alphadash($subject, $replace = '');Regex::digits($subject, $replace = '');Regex::numeric($subject, $replace = '');

You also have access to the underlying match and replace methods for custom patterns:

// Replace interfacepublic static function replace($subject, $pattern, $replacement = '');
// Match interfacepublic static function match($subject, $pattern, bool $allowWhitespace = false): bool;

You can learn more about this package, get full installation instructions, and view the source code on GitHub.

--

--

Poovarasu

Senior PHP/Python Developer @ Mallow Technologies | Laravel & Django | Tech Enthusiast | Code Wizard | Forward-Thinking Techie