regex - Regular Expression Split XML in Java -


i want split xml text parts:

xmlcontent = "<taga>text1<tagb>text2</tagb></taga>"; 

in c# use

string[] splitedtexts = regex.split(xmlcontent, "(<.*?>)|(.+?(?=<|$))"); 

the result

splitedtexts = ["<taga>", "text1", "<tagb>", "text2", "</tagb>", "</taga>"] 

how can in java?

i have tried

string[] splitedtexts = xmlcontent.split("(<.*?>)"); 

but result not expecting.

the parameter split defines delimiter split at. want split before < , after > hence can do:

string[] splitedtexts = xmlcontent.split("(?=<)|(?<=>)"); 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -