I want to write a parser for a bibtex file. In my bibtex-file there is a string booktitle = {Wohnen - Pflege - Teilhabe {\dq}Besser leben durch Technik{\dq}}
. Anyway, I am using JUnit-Tests and a method which should detect and replace {\dg}
to '
or "
. Unfortunately I am not able to write the corresponding java code, for example my following code did not detect the substring?
inproceedingsCitation1 += " booktitle = {Wohnen - Pflege - Teilhabe {\\dq}Besser leben durch Technik{\\dq}},\n";
Corresponding part of my replace-Method:
String afterDg = "";
CharSequence targetDg = "{\\dg}";
CharSequence replacementDg = "\"";
afterDg = afterAe.replace(targetDg, replacementDg);
This regular expression should solve your problem:
String afterDg = afterAe.replaceAll("\\{\\\\dq\\}", "\"");
For more details according to regular expressions, have a look at Vogellas Java Regex Tutorial.