data: <emp_dist_nm>Shyam lal/tester</emp_dist_nm>
code i tried is
Pattern p3 = Pattern.compile("<emp_dist_nm>(\\S+)</emp_dist_nm>");
The pattern is not getting compile, kindly suggest the exact symbol i need to use so that my pattern can compile
data: <emp_dist_nm>Shyam lal/tester</emp_dist_nm>
code i tried is
Pattern p3 = Pattern.compile("<emp_dist_nm>(\\S+)</emp_dist_nm>");
The pattern is not getting compile, kindly suggest the exact symbol i need to use so that my pattern can compile
The pattern does compile, it just does not match the string. You are looking for \S+, but that does not match the space in the name. Instead, you could, e.g., try "everything except <", i.e. [^<]+
Pattern p3 = Pattern.compile("<emp_dist_nm>([^<]+)</emp_dist_nm>");
In fact, since you already have the closing tag after the group you want to capture, you could also just use .+?, i.e. a non-greedy group of any character. Here, the non-greedy ? is important, otherwise it might merge the contents of two such tags and everything in between.
Pattern p3 = Pattern.compile("<emp_dist_nm>(.+?)</emp_dist_nm>");
If you also want to allow empty tags, use * instead of +, i.e. [^<]* or .*?.