Java - Write code to trim First Slash

Requirements

Write code to trim First Slash

Demo

//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));
    }/*w  ww .j  a  v  a 2s  .c  o  m*/

    public static String trimFirstSlash(String str) {
        if (str.startsWith("/")) {
            return str.replaceFirst(Pattern.quote("/"), "");
        }
        return str;
    }
}