I am trying to process text and replace all the occurence that start with "www." with a certain word (in this cases "Banana"), but I want to exclude all the cases in which there is "http://" before the "www".
When I use a positive lookahead it works (only the http://www case changes), but when I use a negative lookahead - both words change.
Can you help me with this one?
String baseString = "replace this: www.q.com and not this:http://www.q.com";
String positiveLookahead = baseString.replaceAll("(?:http://)www([^ \n\t]*)", "Banana");
String negativeLookahead = baseString.replaceAll("(?!http://)www([^ \n\t]*)", "Banana");
//positiveLookahead works (changes only the scond phrase), but positiveLookahead does not (changes both)