WSPlaceholderUtil { public static String findEndTagsAtBeginning( String s ) { Matcher m = endTagsAtBeginningRE.matcher( s ); if ( m.find() ) { return m.group(); } else { return ""; } }  static String replacePlaceholders( String s, Map<Integer, PHData> phmap ); static Map<Integer, PHData> makePlaceholderMap( WSTextSegmentPlaceholder[] holders ); static String restorePlaceholders( String s, Map<Integer, PHData> phmap ); static String findEndTagsAtBeginning( String s ); static String removeEndTags( String s );  }
@Test public void testFindEndTagsAtBeginning() { assertEquals( "No closing tag at all", "", WSPlaceholderUtil.findEndTagsAtBeginning( "Hello" ) ); assertEquals( "End tag in the middle", "", WSPlaceholderUtil.findEndTagsAtBeginning( "Hello<span>World" ) ); assertEquals( "One closing tag at beginning", "</span>", WSPlaceholderUtil.findEndTagsAtBeginning( "</span>Hello" ) ); assertEquals( "Two closing tags at beginning", "</span></span>", WSPlaceholderUtil.findEndTagsAtBeginning( "</span></span>Hello" ) ); assertEquals( "Two closing tags with extra spaces at beginning", "</span> </span>", WSPlaceholderUtil.findEndTagsAtBeginning( "</span> </span>Hello" ) ); assertEquals( "One closing tag at beginning, another in middle", "</span>", WSPlaceholderUtil.findEndTagsAtBeginning( "</span>Hello </span>" ) ); }