Search code examples
javar.java-file

How to replace only IP in url string in file


How to Replace only Ip in the below string in file with java file operation var BOSH_URL = "http://192.168.50.107:7070/http-bind/";


Solution

  • Simply use replaceAll

    BOSH_URL = BOSH_URL.replaceAll("(\\d+.){3}\\d+", "127.0.0.1");