I'm facing an issue with my regex that splits a string into arrays.
Everything is working smoothly except for the fact that I want to retain part of the delimiter.
This is the regex I am using:
(&#?[a-zA-Z0-9]+;)[\s]
In my JavaScript code, I have:
var test = paragraph.split(/(&#?[a-zA-Z0-9]+;)[\s]/g);
The paragraph looks like this:
Current addresses: † Biopharmaceutical Research and Development<br />
‡ Clovis Oncology<br />
§ Pisces Molecular <br />
|| School of Biological Sciences
¶ Department of Chemistry<br />
The problem is arising as I'm getting 10 elements in my array instead of the expected 5. The delimiter is also being included as an element, whereas my intention is to keep the delimiter together with the split element.
Your assistance is greatly appreciated.
EDIT:
The desired result is:
1. † Biopharmaceutical Research and Development<br />
2. ‡ Clovis Oncology<br />
3. § § Pisces Molecular <br />
|| School of Biological Sciences
4. ¶ Department of Chemistry<br />