I need to display a word doc on a webpage. I am using a library named Docx4j to convert .doc to html. This is working fine. But, I'm getting the hyperlinks in the below format.
To search on google go to this link [#?] HYPERLINK \"http://www.google.com/\" [#?][#?] google[#?] and type the text.
I'm able to convert it to
To search on google go to this link (http://www.google.com) google and type the text.
using the below code
String myText = "To search on google go to this link [#?] HYPERLINK \"http://www.google.com/\" [#?][#?] google[#?] and type the text.";
System.out.println(myText);
String firstReplace = myText.replaceAll("\\[", "").replaceAll("\\]", "").replaceAll("#\\?", "");
System.out.println(firstReplace);
String secondReplace = firstReplace.replaceAll("HYPER\\S+\\s+\"", "(");
System.out.println(secondReplace);
String finalReplace = secondReplace.replaceAll("/*\".", ")");
System.out.println("\n" + finalReplace);
Can someone please provide me a regex to convert the above string to
To search on google go to this link google (http://www.google.com) and type the text.
--EDIT--
There are some links which show up as
[#?] HYPERLINK \"http://www.google.com/\" [#?][#?] google page[#?]
I should change them to
google page (http://www.google.com)
How do I do this?