Release 0.9.2

๐Ÿ˜Ž T-Regx is more than happy to announce its third alpha version!! As mentioned, despite the alpha suffix, it's 100% suitable for production use. It doesn't have any known bugs - it's just missing a few time-consuming features.

What's new in this release:

  • Breaking changes
    • Constructor new Pattern() is no longer a part of T-Regx API. Use Pattern::of()/pattern()
    • Renamed Match.parseInt() to Match.toInt() (the same for MatchGroup)
    • Removed pattern()->match()->test()/fails(). From now on, use pattern()->test()/fails()
    • Removed is():
      • is()->delimited()
      • is()->usabled()
      • is()->valid() is changed to valid()
  • Features
    • Added Match.group().replace() ๐Ÿ”ฅ
    • Added pattern()->match()->fluent() ๐Ÿ”ฅ
    • Added pattern()->match()->asInt()
    • Added pattern()->match()->distinct() (leaves only unique matches)
    • Added prepared pattern method Pattern::inject()/Pattern::bind() (see below)
    • In pattern()->match()->groups():
      • Added groups()->forEach()/iterate()
      • Added groups()->flatMap()
      • Added groups()->map()
      • Added group()->fluent()
      • Added groups()->names() (and namedGroups()->names())
      • Added groups()->count() (and namedGroups()->count())
    • Added pattern()->forArray()->strict() which throws for invalid values, instead of filtering them out
  • SafeRegex
    • Added preg::grep_keys() ๐Ÿ”ฅ, that works exactly like preg::grep(), but filters by keys (also accepts PREG_GREP_INVERT)
    • Methods preg::grep(), preg::replace_callback() and preg::replace_callback_array() are now protected from throwing Fatal Errors.
  • Enhancements/updates
    • Method by()->group()->orElse() now receives lazy-loaded Match, instead of a subject
    • Added withReferences() to CompositePattern.chainedReplace()
    • Previously named Pattern::inject() is renamed to Pattern::bind()
    • The Pattern::bind() (old Pattern::inject()) still accepts values as an associative array, but new Pattern::inject() receives values without regard for the keys.
    • Fixed passing invalid types to forArray(). Previously, caused fatal error due to internal implementation.
  • Other
    • Now MalformedPatternException is thrown, instead of CompileSafeRegexException, when using invalid PCRE syntax.
    • Returning Match from replace()->callback() (instead of Match.text() as string)
    • Match +12 is no longer considered a valid integer for isInt()/toInt()
    • Unnamed group will be represented as null in Match.groupNames(), instead of being simply ignored
  • Maintenance

Don't forget about T-Regx

Some of you might have noticed that not many new features have been added to 0.9.2 release candidate, since few weeks. But rest assured! :D Work on T-Regx hasn't slowed a bit! We've just put more effort on a more side-part of T-Regx.

Thanks to the keen eye of T-Regx user, Andreas Leathley, it stroke us that phpDoc in public methods of preg class (so preg::match(), preg::replace(), etc.) were not only outdated, they were incorrect at times. Thanks Andreas! :)

At first, we only wanted to correct the mistakes, but I quickly realized that mere phpDoc inherited from preg_*() methods is not enough :/ That could be easily found on php.net, what T-Regx users could really benefit from is a really extensive, rich, long, detailed and robust documentation.

That's why we've spent a little over a week to create an application that's capable of generating a complex and rich phpDoc for preg class (of course we'll use it for more classes in T-Regx). Main updates for the documentation will include:

  • Robust description of every parameter of every preg_*()
  • Detailed description of every flag used (e.g. PREG_OFFSET_CAPTURE)
  • Rich description of each method, it's relation, similarities and differences to other methods

And it will be much easier to maintain, because every class will have a phpDoc that's not written, but generated.

I'm pretty certain T-Regx is going to have a documentation you've never seen before :D

Of course, there are also some minor changes:

  • We've added pattern()->match()->group()->fluent()
  • Added callback for pattern()->match()->group()->first()
  • Updated detailed description in CONTRIBUTING.md

Keep looking forward to T-Regx 0.9.2! :)

The best Stargazers' Revolutions

I have imagined this moment for a long time. Is it real? Could it be T-Regx got 60 stars ? :D

But what's new.

There is preg_grep() function for filtering an array by a pattern, unfortunately there's no flag or another method to filter it by keys. There is a T-Regx method forArray()->filterByKeys(), but there was no such solution in SafeRegex.

That's why we added preg::grep_keys, which works exactly like preg_grep() but filters an array by keys, instead of values. It's going to be release in 0.9.2.

List of all changes incoming in 0.9.2 is available in ChangeLog.md, with fluent(), unique(), in-place replacements and more.

"The best Stargazers!" Reloaded

Holy guacamole! There were only 30 stars a few weeks ago and we have 40 already!? :D You guys gave us even more reason to release T-Regx 0.9.2 even sooner! Two new features are coming:

  • In-group replacing ๐Ÿ˜ฒ You can now replace a single group inside your subject (not only in replace(), in any method with Match details)
  • Additional prepared patterns method - Pattern::bind()

So keep an eye for 0.9.2 release.

Match details update

Most changes in T-Regx since the last Blog post were to Match details. We added user data (getUserData()/setUserData()) which can be used in chained calls (e.g. filter()->map()).

The second change is isInt()/parseInt() which allow you to handle "real" integers safetly - without the fear of "PHP smart" integers (e.g. PHP thinks that "1e3" is 1000). T-Regx understands that robust applications can't allow numbers to be 10e4 - it should be treated as an invalid integer by default!

And last, Match.group(int|string) is now validated (T-Regx was waiting a bit for this change!). We believe that using an invalid group name is a sign of a bug, so using group(-1) or group('!@#') now throws \InvalidArgumentException, as it's more suitable than assuming that -1 is just an unmatched group.

Santa Clause Day Update

So over 2 months have passed since the last blog entry - much have changed. It's all described in ChangeLog.md on github, so there's no reason for rewriting it again.

One big change is Prepared Patterns - which lets you handle user input or unsafe characters in your patterns. It's got a dedicated section in Docs, too.

Except for that, there's a discussion section in Help - feel free to ask questions or propose features!

Welcome T-Regx

The library changes its name! Now it's called T-Regx! It's a combination of words "T-Rex" - the dinosaur - and "RegExp".

Also, I've invested much more time into the development of CleanRegex T-Regx. Read on, for a detailed list of features.

Support for PHP 5.3

Hello there! Another update, this time there's more to it - much has changed.

Here's a quick list:

  • ReadMe.md is now more throughout
  • CleanRegex runs on Travis and Coveralls
  • The library can now be required using Composer
  • CleanRegex supports PHP 5.3
  • Handling compile pattern exceptions and runtime pattern exceptions
  • Passing callbacks with detailed object parameters (Match and ReplaceMatch).
  • Add a facade Pattern::of()

In addition, I'd like to give a quick thanks to Bartek - my friend currently working at Thulium - for a nice suggestion :)