A set of ready-made regex helper methods for use in your Laravel application.

Overview

Regex

A set of ready-made regex helper methods for use in your Laravel application.

Latest Stable Version

Installation

composer require hotmeteor/regex

Usage

Regex comes with a set of common regex patterns that are ready to use. These patterns can be used to either replace or match against values. Every pattern is both case-insensitive and able to interpret unicode characters, and should support all languages.

Additionally, beyond the methods below both the underlying match and replace methods are exposed to pass in custom patterns.

Match

Match methods return true or false depending on if the subject value contains anything but the expected pattern.

You may optional allow whitespace by passing true as a second parameter.

Methods

Regex::isAlpha($subject, $allowWhitespace = false)

Checks if the value contains anything but letters.


Regex::isAlphanumeric($subject, $allowWhitespace = false)

Checks if the value contains anything but letters and numbers.


Regex::isAlphadash($subject, $allowWhitespace = false)

Checks if the value contains anything but letters, numbers, and .-_.


Regex::isDigits($subject, $allowWhitespace = false)

Checks if the value contains anything but integers.


Regex::isNumeric($subject)

Checks if the value contains anything but numeric values, including decimals and negative numbers. Does not allow for whitespace.


Regex::isUuid($subject)

Checks if the value is a UUID. Does not allow for whitespace.

Replace

Replace methods replace anything in the subject value that doesn't match the pattern with the provided replacement.

The default replacement is nothing: it just removes the character.

Methods

Regex::alpha($subject, $replace = '')

Replaces all characters in the subject except letters.


Regex::alphanumeric($subject, $replace = '')

Replaces all characters in the subject except letters and numbers.


Regex::alphadash($subject, $replace = '')

Replaces all characters in the subject except letters, numbers, and .-_.


Regex::digits($subject, $replace = '')

Replaces all characters in the subject except integers.


Regex::numeric($subject, $replace = '')

Replaces all characters in the subject except numeric values, including decimals and negative numbers.


Regex::uuid($subject)

Replaces all characters in the subject to form it into a UUID. Does not accept a replacement value.

You might also like...
I made my own simple php framework inspired from laravel framework.

Simple MVC About Since 2019, I started learning the php programming language and have worked on many projects using the php framework. Laravel is one

Fast PHP framework made with very loose optional components.
Fast PHP framework made with very loose optional components.

Nimble is a super fast mini-framework for PHP built on top of optional loose components. Installation Clone the repository $ git clone [email protected]:

PIP is a tiny application framework built for people who use a LAMP stack.

PIP is a tiny application framework built for people who use a LAMP stack. PIP aims to be as simple as possible to set up and use.

a framework for WebDevelop based on the mvc structure. The name of this project for Fun because everyone can use it. Completely simple and powerful structure for all your projects

A_A (-.-) ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ |-| █▄─▄▄─█▄─██─▄█─▄▄▄▄█─▄▄▄▄█▄─█─▄█─▄▄▄─██▀▄─██─▄

Supercharge your Laravel application's performance.

Introduction Laravel Octane supercharges your application's performance by serving your application using high-powered application servers, including

This package provides a high performance HTTP server to speed up your Laravel/Lumen application based on Swoole.
This package provides a high performance HTTP server to speed up your Laravel/Lumen application based on Swoole.

This package provides a high performance HTTP server to speed up your Laravel/Lumen application based on Swoole.

This repository contains a library of optional middleware for your Slim Framework application

Slim Framework Middleware This repository contains a library of optional middleware for your Slim Framework application. How to Install Update your co

Quite possibly the smallest MVC framework you'll ever use.

Swiftlet Swiftlet is quite possibly the smallest MVC framework you'll ever use. And it's swift. Licensed under the MIT license. Buzzword compliance ✔

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!
A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast! Condensed in a single ~65KB file

Releases(v0.4)
Owner
Adam Campbell
Adam Campbell
A set of PSR-7 object decorators providing useful convenience methods

Slim-Http Slim PSR-7 Object Decorators Installation It's recommended that you use Composer to install this library. $ composer require slim/http This

Slim Framework 136 Sep 29, 2022
BEdita, ready to use back-end API, extensible API-first Content Management

BEdita, a back-end API BEdita 4 is a ready to use back-end API to handle the data of your mobile, IoT, web and desktop applications. It's also an exte

BEdita 65 Oct 31, 2022
Yii2 console application used to write our processors of methods to responsible to client calling.

Microservice Application Skeleton Yii2 console application used to write our processors of methods to responsible to client calling. This application

Jafaripur 0 Mar 10, 2022
Production ready Dockerfile for Octane powered Laravelish web services and microservices

Laravel Octane Dockerfile A pretty configurable and production ready multi-stage Dockerfile for Octane powered Laravelish web services and microservic

Exalab.co 245 Dec 26, 2022
Silex Skeleton - a fully-functional Silex application that you can use as the skeleton for your new applications

Silex Skeleton - a fully-functional Silex application that you can use as the skeleton for your new applications

Silex 789 Dec 5, 2022
Domain Driven Design PHP helper classes

carlosbuenosvinos/ddd This library will help you with typical DDD scenarios, for now: Application Services Interface Transactional Application Service

Domain-Driven Design in PHP 642 Dec 28, 2022
Slim Framework view helper built on top of the Twig templating component

Slim Framework Twig View This is a Slim Framework view helper built on top of the Twig templating component. You can use this component to create and

Slim Framework 321 Dec 16, 2022
A set of shady Slim Framework middlewares that can solve some annoyances...

Shady A set of shady Slim Framework middlewares that can solve some annoyances... What does it contain? Available middlewares: ApacheVirtualHostFix Ur

Jan-Age Laroo 7 Jun 22, 2021
I made my own simple php framework inspired from laravel framework.

Simple MVC About Since 2019, I started learning the php programming language and have worked on many projects using the php framework. Laravel is one

null 14 Aug 14, 2022