I'm trying to remove the preceding zeros of numbers present in below query
String query = "or(contains(number,'04506'),contains(name,'04506'),contains(vendorInfo.name,'04506'),contains(vendorInfo.number,'04506'),contains(costCategories.name,'04506')";
I'm using below regex
query = query.replaceAll("\\b0+","");
Problem is, it also removes zero, if we provide a query with a timestamp to it, e.g.
query = "ge(dateCreated,'2013-01-18T19:30:00.000Z')";
You can use negative lookarounds to not remove the zero followed by or preceded by any of
-,:,.orT.Output: