I am trying to skip the first semi colon in the string that looks like the one below and do a spilt on the rest of the semi colon using a regular expression
My string looks something like this
lines = </li> <li> Urinary tract infection </li> <li> Respiratory infection </li> <li> Sinus problems; and </li> <li> Ear infections; <li> Some more info </li>
I am using the below ruby code to do split this at every semi colon except the first one
lines.split(/(?<!\\\\);/)
My expected output is
["</li> <li> Urinary tract infection </li> <li> Respiratory infection </li> <li> Sinus problems; and </li> <li> Ear infections","<li> Some more info </li>" ]
Note that the string could be long with any number of semi colons but I want to prevent the splitting happening only from the first semi colon. I would appreciate some help here if keep the first occurrence of the semi colon intact.
Aucun commentaire:
Enregistrer un commentaire