, Java , .{0,1000}, .
Check out this approach using 2 regular expressions or 1 regular expression and 1 replace. Choose the one that works best (I removed the line break \nfrom the first line of input to show the error with a simple one replace):
String input = "<user_input><UserInput Question=\"test Q?\" Answer=<value>0</value><sam@testmail.com>\"\n</user_input>";
String st = input.replace("><", " ").replaceAll("(?<=Answer=.{0,1000})[<>/]+(?=[^\"]*\")", "");
String st1 = input.replaceAll("(?<=Answer=.{0,1000})><(?=[^\"]*\")", " ").replaceAll("(?<=Answer=.{0,1000})[<>/]+(?=[^\"]*\")", "");
System.out.println(st + "\n" + st1);
Program Output:
<user_input UserInput Question="test Q?" Answer=value0value sam@testmail.com"
</user_input>
<user_input><UserInput Question="test Q?" Answer=value0value sam@testmail.com"
</user_input>
source
share