We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
importjava.io.*;importjava.util.*;importjava.text.*;importjava.math.*;importjava.util.regex.*;publicclassTagExtractor{publicstaticvoidmain(String[]args){Scannerin=newScanner(System.in);inttestCases=Integer.parseInt(in.nextLine());while(testCases>0){Stringline=in.nextLine();//Write your code hereStringtagRegex="<(.+)>(\\w|\\d|\\s)+</\\1>";PatterntagPattern=Pattern.compile(tagRegex);MatchertagMatcher=tagPattern.matcher(line);Stringresult="None";if(tagMatcher.find()){StringtagName=tagMatcher.group(1);result=tagMatcher.group(0).replaceAll("<"+tagName+">","");result=result.substring(0,result.indexOf("<"));}System.out.println(result);testCases--;}}}
For some reason I got errors.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Tag Content Extractor
You are viewing a single comment's thread. Return to all comments →
For some reason I got errors.