Closed danon closed 3 years ago
Feature description
Add ability to create formatted patterns, but with ability to escape them.
With the snippet below, there's no possibility from the user perspective (the supplier of the mask/format string) to make e literal.
e
Pattern::format('welcome:e', [ 'e' => '\w+' ]);
We could created new method formatEscapable, which means any value in the format can be escaped.
formatEscapable
Pattern::formatEscapable('welcome:e', '\\', [ 'e' => '\w+', 'e\e' => 'x', // disallowed 'e\\' => 'x', // disallowed '\\' => 'siema' // disallowed ]);
Question arises, what happens when someone passes quoted character that's not in the patterns, or leaves it as the last character in the mas
Pattern::formatEscapable('\e \x \', '\\', ['e' => '\w+',]);
Wha should be the result? Replace \e but not \x and \? What if someone escaps the escape? Should the escape be the same? Disallowed? Or customizable?
\e
\x
\
x
\\
Descoped
Feature description
Add ability to create formatted patterns, but with ability to escape them.
With the snippet below, there's no possibility from the user perspective (the supplier of the mask/format string) to make
e
literal.We could created new method
formatEscapable
, which means any value in the format can be escaped.Question arises, what happens when someone passes quoted character that's not in the patterns, or leaves it as the last character in the mas
Wha should be the result? Replace
\e
but not\x
and\
? What if someone escaps the escape? Should the escape be the same? Disallowed? Or customizable?\e
, we should treat it ase
literal\x
we should treat it asx
literal\\
.. ?\
at the end of the format?