In below line if we have single quote (') then we have to replace it with '||''' but if we have single quote twice ('') then it should be as it is.
I tried below piece of code which is not giving me proper output.
Code Snippet:
static String replaceSingleQuoteOnly = "('(?!')'{0})";
String line2 = "Your Form xyz doesn't show the same child''s name as the name in your account with us.";
System.out.println(line2.replaceAll(replaceSingleQuoteOnly, "'||'''"));
Actual Output by above code:
Your Form xyz doesn'||'''t show the same child''||'''s name as the name in your account with us.
Expected Result:
Your Form xyz doesn'||'''t show the same child''s name as the name in your account with us.
Regular expression is replacing child''s with child''||'''s. child''s should remain as it is.