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));
    }//from  w  w w. j a va2 s  . c om

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