Repository navigation
Releases: t-regx/T-Regx
Release list
0.9.5 - Alternation in prepared patterns!
😎 T-Regx The Dinosaur is really proud to announce its second beta version! Despite the beta suffix, it's 100% suitable for production use. It doesn't have any known bugs - check out the issues. There is a few breaking changes (since that's a 0.* version), but there are also improvements and new feautres.
The detailed list of changes is in ChangeLog.md.
Here's a summary:
-
Breaking changes
- Removed
iterate()method, which was only used as a substitute forforEach(), pre PHP 7.0, when
keywords couldn't be used as method names. - Renamed
pattern()->match()->forFirst()tofindFirst()#70
- Removed
-
Features
- Added
match()->group()->findFirst()#22 #70 - Added alternating groups in prepared patterns 🔥
Pattern::bind(),Pattern::inject()andPattern::prepare()can now acceptstring[], which will be treated as a regex alternation group!is similar toPattern::bind('Choice: @values', [ 'values' => ['apple?', '[orange]', 'pear'] ]);
The alternation is also optimized forPattern::of('Choice: (apple\?|\[orange\]|pear)')
ianduflags, for example it will remove case-insensitive duplicates (likefooandFOOwheniflag is used).
- Added
That's it for this release, stay tuned!
0.9.4 - Exception changes and groupBy!
What's new, new, new?
This release brings updates in exceptions (namespaces, new detailed exceptions) and a groupBy() method.
Exceptions
In previous realase we renamed SafeRegexException to PregException. In this, we're renaming CleanRegexException to PatternException. So now, those two general exceptions sync nicely with their base methods:
try {
return preg::match('/Foo/', $subject);
} catch (PregException $e) {try {
return pattern('Foo')->test($subject);
} catch (PatternException $e) {They both extend RegexException - base for all exceptions thrown by T-Regx. So that's the first thing.
The second exception update - previously, every exception thrown based on preg_last_error() method was RuntimePregException. Now, each error has a dedicated exception, which can be caught separately:
try {
return preg::match($pattern, $subject);
} catch (BacktrackLimitPregException $exception) {
} catch (Utf8OffsetPregException $exception) {The detailed list of changes is in ChangeLog.md.
groupBy()
This realase also comes with a brand new method - groupBy() which groups matches by a capturing group (name or index). It can match strings, offsets and also map them with map() and flatMap(). Additionally, it can be chained with filter() to leave out unwanted matches:
return pattern('(\d)(?cm|mm) ')->match($strings)
->filter(function (Match $match) {
return $match->group(1)->toInt() % 2 == 0;
})
->groupBy('unit')
->map(function (Match $match) {
return $match->group(1)->toInt() * 100;
});0.9.2 - You're in for a treat
😎 T-Regx The Dinosaur is really proud to announce its first beta version! Despite the beta suffix, it's 100% suitable for production use. It doesn't have any known bugs - check out the issues. There is a few breaking changes (since that's a 0.* version), but there are also a looot of improvements and new feautres.
The detailed list of changes is in ChangeLog.md.
Here's a summary:
- Breaking changes
- Refactored entry points -
Pattern::of()/pattern()andPattern::pcre()(see more in ChangeLog.md) - Renamed
parseInt()totoInt() - Removed
pattern()->match()->test()/fails(). From now on, usepattern()->test()/fails() - Removed
is()(see more in ChangeLog.md) - Refactored
split()(see more in ChangeLog.md)
- Refactored entry points -
- Features
- Added
Match.group().replace()🔥 - Added to
pattern()->match():fluent(),
asInt(),
distinct(),
groups(),
offsets()->fluent(),
group(string)->offsets()->fluent()
- Added
pattern()->forArray()->strict()which throws for invalid values - Added
Pattern::inject()/Pattern::bind()
- Added
- SafeRegex
- Added
preg::grep_keys()🔥
- Added
- Other
- Now
MalformedPatternExceptionis thrown, instead ofCompileSafeRegexException, when using invalid PCRE syntax.
- Now
That's just a handful, the more detailed description of this realease is in ChangeLog.md.
0.9.1
😎 T-Regx The Dinosaur is proud to announce its second alpha version! It doesn't have any known bugs - it's just missing a few time-consuming features.
What's new in this release:
- UTF8-safe method
textLength()forMatchandMatch.group() groupsCount()method forMatchdetails - unsurprisingly just counts the groups (without duplicates of named and regular groups)
And more changes, that required a large part of replacing core to be rewritten, to allow more control over unmatched groups:
- Methods
by()->group()->orIgnore()andby()->group()->orElse() - Method
by()->group()->callback()which acceptsMatchGroupas an argument - Method
by()->group()->orElse()now receives lazy-loadedMatch, instead of a less useful - subject
The new features are already described in the documentation at t-regx.com :)