I have a small piece of relic code written in Javascript that scans a web page source and looks for the pattern.
I am migrating the functuanality to a Java program. So, my questiong is how can I parse a JavaScript regular expression to a java one with some kind of find and replace function?
For example my JavaScript Regex currently reads (as a String)
RegEx = "/(\\/addthis_widget\\.(js|php)|\\.addthis\\.com\\/js\\/widget\\.(js|php))/i";
I found this old post on stackoverflow:
How to convert javascript regex to safe java regex?
which sudgests that this would do the trick:
strOutput.replace("/{{[^]*?}}/g","");
However, this does not seem robust enough and does not produce a RegEx which is recognised by the compiler.