Regex based string split in Java

Vignesh :
String delimiterRegexp = "(;|:|[^<]/)";
String value = "get/time/pick me <i>Jack</i>";
String[] splitedTexts = value.split(delimiterRegexp);
for (String text : splitedTexts) {
System.out.println(text);
}

Output:
ge
tim
pick me <i>Jack</i>

Expected Result: 
get
time
pick me <i>Jack</i>

A character is getting added as delimeter along with /. Could anyone help me out to write regex to split text based on delimeter"/" and it should ignore xml end tag"

Yassin Hajaj :

[^<]/ will match e/ and t/

use a lookbehind instead, it will have the wanted behaviour to only consider / as separator if it's not a closing tag

On regex101.com

(?<!<)/

The whole regex

(;|:|(?<!<)/)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=87339&siteId=1