JS regex split can return also matched results
In Javascript by using:
"One <a> Two <b> Three".split(/<[a-z]>/g)
We will get in result:
(3) ["One ", " Two ", " Three"]
By adding parentheses to this regex we can receive also matched results:
"One <a> Two <b> Three".split(/(<[a-z]>)/g)
Result:
(5) ["One ", "<a>", " Two ", "<b>", " Three"]
Tweet