How can I get the boundaries of a regular expression?
Lets say I have a string that I need to split into an array based on a pattern. Many language split
methods will remove the things matched by the pattern causing a split of a string
testtestt
on the regular expression
.{2}
ending up with a result of
t
This is not the result I wanted so how can I use a regular expression only to capture the borders of what is matched with the same scenario above being matched as
te|st|te|st|t
and as a result being split into an array of
['te','st','te','st','t']
?
Note: This is not language specific and the ideal answer would be a regular expression instead of a piece of code exclusive to certain languages.
from Recent Questions - Stack Overflow https://ift.tt/2Jby6lv
https://ift.tt/eA8V8J
Comments
Post a Comment