String link[] = text.split("\\b");
I am using this code to split my line of text. The problem here is if my sentence contains "-" for example mithun-debnath then also it is separating the sentence. My objective is to split the sentence with all possible delimiters except "-".ie if the sentence "yes,i love my country very-much" then my array should contain link[0]=yes link[1]=i link[2]=love link[3]=my link[4]=country link[5]=very-much.I have not able to come out with an way to ignore "-" in ("\\b").
String link[] = text.split("(?!-)(?<!-)\\b");
Add a lookahead
for the same.See demo.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.