I have a regex which will split my string into arrays.
Everyything works fine except that I would like to keep a part of the delimiter.
Here is my regex:
(&#?[a-zA-Z0-9]+;)[\s]
in Javascript, I am doing:
var test = paragraph.split(/(&#?[a-zA-Z0-9]+;)[\s]/g);
My paragraph is as followed:
Current addresses: † Biopharmaceutical Research and Development<br />
‡ Clovis Oncology<br />
§ Pisces Molecular <br />
|| School of Biological Sciences
¶ Department of Chemistry<br />
The problem is that I am getting 10 elements in my array and not 5 as I should. In fact, I am also getting my delimiter as an element and my goal is to keep the delimiter with the splited element and not to create a new one.
Thank you very much for your help.
EDIT:
I would like to get this as a result:
1. † Biopharmaceutical Research and Development<br />
2. ‡ Clovis Oncology<br />
3. § § Pisces Molecular <br />
|| School of Biological Sciences
4. ¶ Department of Chemistry<br />
, nothing else. – Milos Cuculovic Sep 07 '12 at 11:55
` elements then I might have a solution for you. If it ever gets more complicated though, my solution would fall apart. – Elliot Bonneville Sep 07 '12 at 11:56
and special characters can be in the HTML. My goal is to split the string in elements starting with special characters &xxxx; I can do it with my regx but the problem is that I am also catching the delimiter as a new element. – Milos Cuculovic Sep 07 '12 at 11:58