Release 0.9.5 - Alternation in prepared patterns!
This release brings alternation in prepared patterns!
Up to this point, there was no reasonable way to create a pattern from a variable number of inputs, for example
you allow your users to input 0, 1 or more tags, which later should be used in a pattern. In procedural world, probably
array_map()
with preg::quote()
would do the job, but wait! You don't have to code, it's already here:
In other words:
creates a pattern:
Rest assured:
- the values are quoted with
preg::quote()
, to protect you from malicious code - the group is non-capturing (use
'My tag is: "(@tags)"'
for a capturing group, to be used withgroup()
)
The alternation is really smart too - if you use i
or u
flag, T-Regx will perform certain optimization,
for example:
then it wil collapse foo
and FOO
, since i
flag is used:
That's it in this release! Stay tuned :)