LeadingSlashRegexTransformer { public static String trimLeadingSlashes(final String regex) { return new LeadingSlashRegexTransformer(regex).transform(); } private  LeadingSlashRegexTransformer(final String regex); static String trimLeadingSlashes(final String regex); String transform();  }
@Test public void expectedLeadingSlashTransformations() { assertThat(trimLeadingSlashes(""), is("")); assertThat(trimLeadingSlashes("/"), is("")); assertThat(trimLeadingSlashes(".*"), is(".*")); assertThat(trimLeadingSlashes("/.*"), is(".*")); assertThat(trimLeadingSlashes(".*/"), is(".*(^|/)")); assertThat(trimLeadingSlashes("/.*/"), is(".*/")); assertThat(trimLeadingSlashes(".?/foo/"), is(".?(^|/)foo/")); assertThat(trimLeadingSlashes("/+foo/"), is("(^|/)+foo/")); assertThat(trimLeadingSlashes("/com|/org"), is("com|org")); assertThat(trimLeadingSlashes("(?!.*/struts/.*).*/apache/.*"), is("(?!.*(^|/)struts/.*).*(^|/)apache/.*")); assertThat(trimLeadingSlashes("((([a-z[A-Z]]/)?([0-9]?/)*)|.*/?)/foo"), is("((([a-z[A-Z]]/)?([0-9]?(^|/))*)|.*/?)foo")); }