You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're coming right here up to you, to explain the reasons behind the deprecation and further removal of this piece of feature from T-Regx.
Detail.substitute() and focus() in replacements are really the same idea, simply speaking they were supposed to replace only single group from a match with a new value.
The idea is simple, let's say we want to update units in a string
pattern('\d+([ckm]?m)')->replace("I'm 187cm, I live 356m from shop, and 2km from the beach")->focus(1)->with('X');
we'd get
"I'm 187X, I live 356X from shop, and 2X from the beach"
The idea was good, at first glance, and we actually used it multiple times in our projects, but unfortunately, sorry to say that, but we have made a huge design flaw, while adding focus() to the library.
The problem
The focus() and Detail.substitute() assumptions are only correct, as long as we're using regular indexed and named groups. When we introduce groups in look-arounds, like (?=.(foo).), or groups before pattern reset (foo)\K(bar), then the current T-Regx implementation returns very weird results, and it's actually impossible to make it work correctly, since look-arounds can overlap each other indefinetely.
Deprecation and removal
We're deprecating focus() and Detail.substitute(), it won't be part of T-Regx 1.0.
Replacement
We're planning on delivering a separate package, maybe called rawr/t-regx-focus, that will include replacement API for the focus functionallity, but it will be described in detail, that the solution isn't complete (breaks for look-arounds and resets). We can't have such incomplete solutions in the core of the library
Final thoughts
We're sorry for not thinking the focus idea throught before, we're trying to fix it. We apologize.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello, all dinosaur lovers!
We're coming right here up to you, to explain the reasons behind the deprecation and further removal of this piece of feature from T-Regx.
Detail.substitute()
andfocus()
in replacements are really the same idea, simply speaking they were supposed to replace only single group from a match with a new value.The idea is simple, let's say we want to update units in a string
we'd get
"I'm 187X, I live 356X from shop, and 2X from the beach"
The idea was good, at first glance, and we actually used it multiple times in our projects, but unfortunately, sorry to say that, but we have made a huge design flaw, while adding
focus()
to the library.The problem
The
focus()
andDetail.substitute()
assumptions are only correct, as long as we're using regular indexed and named groups. When we introduce groups in look-arounds, like(?=.(foo).)
, or groups before pattern reset(foo)\K(bar)
, then the current T-Regx implementation returns very weird results, and it's actually impossible to make it work correctly, since look-arounds can overlap each other indefinetely.Deprecation and removal
We're deprecating
focus()
andDetail.substitute()
, it won't be part of T-Regx 1.0.Replacement
We're planning on delivering a separate package, maybe called
rawr/t-regx-focus
, that will include replacement API for the focus functionallity, but it will be described in detail, that the solution isn't complete (breaks for look-arounds and resets). We can't have such incomplete solutions in the core of the libraryFinal thoughts
We're sorry for not thinking the focus idea throught before, we're trying to fix it. We apologize.
Beta Was this translation helpful? Give feedback.
All reactions