I have to remove all slash (/) from the beginning of string. So I have written
while (convertedUrl.startsWith("\\"))
{
convertedUrl = convertedUrl.substring(1);
}
Above code creates string for each substring. Is there any better way to write this code in java 8 or later? How can I do it keeping mind memory utilisation and performance.
\but in your question you claim you want to remove/so which is it?convertedUrl = convertedUrl.replaceFirst("^\\\\+", "");(if you want to remove series of\at beginning of string). Change\\\\to/if you want to remove/.