Im trying to replace all mentions of .html in a html fine to .jsp. For example if i had:
<html>
<h1>
Some Text Here
</h1>
<a href ="page1.html"> Go to Page1
</html>
i would want to ONLY replace the .html in the link.
By using:
String replace= src.replaceAll(".html", ".jsp");
i succesfully replace the .html in the link but i also replace the html at the start and at the beginning despite them not having a "." in front of them? Any ideas on how to fix this PLEASE
04-15-2006, 01:44 PM
nspils
Look at the Pattern class, search to match the pattern.
Did you try to use an escape code before the period? ("\.html")
04-18-2006, 02:42 AM
graviton
it should be ("\\.html"), since \ has to be escaped within strings with \\. the dot is the regular expression for anycharacter.