jhinkelmann / regex-helper
A simple Regex Helper that simply nobody should actually use
Requires
None
Requires (Dev)
- phpunit/phpunit: ^13.4
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-11-24 12:43:45 UTC
README
The package has three main functions:
RegexHelper::isValidEmailRegexHelper::extractNumbersRegexHelper::maskSensitiveData
It also has another function that can be used to generally match regexes it is called whit RegexHelper::match.
The package will emit debug information to stdout if the environment variable TESTENV is set to testing.
validation
The regexes are stored without the by php requested starting and end "/" the options can be added in the match function.
Generally it is not recommended to use regex to validate E-Mails neither is it to recognize telephone numbers.
Because of this the library will only recognize a subset of E-Mail addresses furthermore the matching of telephone numbers in maskSensitiveData by default generalizes to recognizing any number to make sure that it catches all. If a less aggressive matching for telephone number is wanted the library also has a regex for that purpose called $FILTERGermanTelephoneNumbers it trys to match german telephone numbers that comply with: Din 5008 or E.123 it also needs the correct spacing to be present.
The extractNumbers function extracts all digits from a string doing so it trys to figure out if the number is using a dot or a comma as a decimal point the other one can then be used to separate each hundredth of a number if no previous match was found it will fall back to any number \d*.
The result of the function is ordert in the same order as in which the numbers where in the text.
list of predefined regexes
- ´RegexHelper::$FILTEREMAILS´
- ´RegexHelper::$FILTERTelephoneNumbers´
- ´RegexHelper::$FILTERKreditkardNummer´
- ´RegexHelper::$FILTERGermanTelephoneNumbers´
recommendation
DO NOT USE THIS!! for anything else but extracting Numbers