I was able to achieve it using Java program. I used Solr-query to find all ID starting with ABC.com. I got URL corresponding to that ID and replaced ABC.com with XYZ.com and kept the rest of the path same. Used set command and updated all the URLs(only URL field) using while loop.
String urlString = "http://localhost:8090/solr/collectionName";
SolrClient solrClient = new HttpSolrClient.Builder(urlString).build();
SolrQuery query=new SolrQuery();
query.setQuery("id:*ABC*");
query.setRows(2147483647);
QueryRequest req = new QueryRequest(query);
QueryResponse response = req.process(solrClient);
SolrDocumentList docList=response.getResults();
Iterator <SolrDocument> itr=docList.iterator();
String IdValue="";
Map<String, String> cmd1;
Map<String, String> cmd2;
UpdateRequest ureq=new UpdateRequest();
while(itr.hasNext()){
JSONObject resultItems = new JSONObject();
SolrDocument doc= itr.next();
IdValue=(String)doc.getFieldValue("id");
SolrInputDocument newdoc = new SolrInputDocument();
cmd1 = new HashMap<String, String>();
String URL=IdValue.replace("www.ABC.com", "www.XYZ.com");
cmd1.put("set", URL);
newdoc.addField("id", IdValue);
newdoc.addField("url", cmd1);
ureq.add(newdoc);
cmd1=null;
cmd2=null;
}
NamedList res = solrClient.request(ureq);
System.out.println(" response "+res);
solrClient.commit();
solrClient.close();