Download the PHP package thejano/easy-php-regex without Composer
On this page you can find all versions of the php package thejano/easy-php-regex. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download thejano/easy-php-regex
More information about thejano/easy-php-regex
Files in thejano/easy-php-regex
Download thejano/easy-php-regex
More information about thejano/easy-php-regex
Files in thejano/easy-php-regex
Vendor thejano
Package easy-php-regex
Short Description A human-readable regex builder for PHP
License MIT
Package easy-php-regex
Short Description A human-readable regex builder for PHP
License MIT
Please rate this library. Is it a good library?
Informations about the package easy-php-regex
EasyRegex
A Human-Readable Regex Builder for PHP
EasyRegex is a fluent and human-readable regex builder for PHP that simplifies constructing complex regular expressions without manually writing regex patterns.
Installation
To install this package using Composer, run:
Usage
Creating Regex Patterns
Use the EasyRegex
class to build and generate regex patterns fluently.
Example: Matching an Email Address
Example: Validating a Strong Password
Example: Matching a URL
Available Methods
Character Classes
digit()
- Matches a digit (\d
)word()
- Matches a word character (\w
)whitespace()
- Matches a whitespace character (\s
)nonWhitespace()
- Matches a non-whitespace character (\S
)letter()
- Matches a letter ([a-zA-Z]
)anyCharacter()
- Matches any character (.
)
Quantifiers
optional()
- Matches zero or one times (?
)exactly(int $n)
- Matches exactlyn
times ({n}
)atLeast(int $n)
- Matches at leastn
times ({n,}
)atMost(int $n)
- Matches up ton
timesbetween(int $min, int $max)
- Matches betweenmin
andmax
times ({min,max}
)oneOrMore()
- Matches one or more times (+
)zeroOrMore()
- Matches zero or more times (*
)
Grouping & Anchors
startGroup()
- Starts a non-capturing group ((?:
)startCaptureGroup()
- Starts a capturing group ((
)startNamedGroup(string $name)
- Starts a named group ((?<name>
)endGroup()
- Ends a group ()
)startAnchor()
- Matches the beginning of the string (^
)endAnchor()
- Matches the end of the string ($
)
Lookaheads & Lookbehinds
negativeLookahead(string $pattern)
- Negative lookahead ((?!pattern)
)positiveLookahead(string $pattern)
- Positive lookahead ((?=pattern)
)positiveLookbehind(string $pattern)
- Positive lookbehind ((?<=pattern)
)negativeLookbehind(string $pattern)
- Negative lookbehind ((?<!pattern)
)
Flags
global()
- Applies the global (g
) flagcaseInsensitive()
- Applies the case-insensitive (i
) flagmultiline()
- Applies the multiline (m
) flagdotAll()
- Applies the dot-all (s
) flagsticky()
- Applies the sticky (y
) flag
Unicode Support
unicodeChar(string $variant = '')
- Matches a Unicode letter (\p{L}
)unicodeDigit()
- Matches a Unicode digit (\p{N}
)unicodePunctuation()
- Matches a Unicode punctuation (\p{P}
)unicodeSymbol()
- Matches a Unicode symbol (\p{S}
)
Special Helpers
escapeLiteral(string $text)
- Escapes special charactersipv4Octet()
- Matches an IPv4 octet ((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)
)protocol()
- Matcheshttp
orhttps
www()
- Matches optionalwww.
tld()
- Matches a top-level domain (\.[a-zA-Z]{2,}
)path()
- Matches a URL path ((\/\w*)*
)
Generating Regex Patterns
toString()
- Returns the raw regex patterntoRegExp()
- Returns the full regex pattern wrapped in/.../
Running Tests
To run the test suite using Pest, execute:
License
This package is open-sourced software licensed under the MIT license.
Author
Created by Pshtiwan Mahmood.
All versions of easy-php-regex with dependencies
PHP Build Version
Package Version
Requires
php Version
>=7.4
The package thejano/easy-php-regex contains the following files
Loading the files please wait ....