Write code to trim First Slash
//package com.book2s; import java.util.regex.Pattern; public class Main { public static void main(String[] argv) { String str = "/book2s.com"; System.out.println(trimFirstSlash(str)); }// www. j a v a 2s.co m public static String trimFirstSlash(String str) { if (str.startsWith("/")) { return str.replaceFirst(Pattern.quote("/"), ""); } return str; } }