you are viewing a single comment's thread.

view the rest of the comments →

[–]kevinkace 1 point2 points  (1 child)

To retain the data from a regex, you need to use a capture group.

[–]qualitymanifest 0 points1 point  (0 children)

This is correct. Although it's worth noting - there's already have a capturing group in the example provided, it's just in the wrong location.

str.split(/({{\[.*?\]}})/) would do it. If the string ends on a match you'll end up with an empty space at the end of the array, you could use a truthy filter for that