Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Your code works fine for me... here's my test code:-</p> <pre><code>public class StringReplaceTest { public static String replaceMe(String str) { String cont = "For the pictures of animal please visit this site http://www.example.net/animals/cat_345_456.JPG . Also more details visit this link also http://www.moredetails.com/example/imgs/nwr_1453446_83223_429054_1603367_42.PNG?Id=1450686&amp;lid=423454&amp;idp=4402767&amp;ps=4563223&amp;circle=4&amp;type=2&amp;zw=264&amp;zh=150&amp;v=5&amp;url=NA&amp;uid= . Thanks visiting us."; return Pattern.compile(str, Pattern.LITERAL).matcher(cont).replaceFirst(Matcher.quoteReplacement("replace string")); } @Test public void testOne() { String str = "http://www.moredetails.com/example/imgs/nwr_1453446_83223_429054_1603367_42.PNG?Id=1450686&amp;lid=423454&amp;idp=4402767&amp;ps=4563223&amp;circle=4&amp;type=2&amp;zw=264&amp;zh=150&amp;v=5&amp;url=NA&amp;uid="; String actual = StringReplaceTest.replaceMe(str); String expected = "For the pictures of animal please visit this site http://www.example.net/animals/cat_345_456.JPG . Also more details visit this link also replace string . Thanks visiting us."; assertEquals(expected, actual); } @Test public void testTwo() { String str = "http://www.example.net/animals/cat_345_456.JPG"; String actual = StringReplaceTest.replaceMe(str); String expected = "For the pictures of animal please visit this site replace string . Also more details visit this link also http://www.moredetails.com/example/imgs/nwr_1453446_83223_429054_1603367_42.PNG?Id=1450686&amp;lid=423454&amp;idp=4402767&amp;ps=4563223&amp;circle=4&amp;type=2&amp;zw=264&amp;zh=150&amp;v=5&amp;url=NA&amp;uid= . Thanks visiting us."; assertEquals(expected, actual); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload