Hackerrank – Java Solution – Tag Content Extractor Solution

HackerRank Problem Solution

Problem Name –  Tag Content Extractor
Problem Link –   Tag Content Extractor
Level – String

Java Code

import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Solution {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int testCases = Integer.parseInt(scan.nextLine());

/* Solution assumes we can't have the symbol "<" as text between tags */
while (testCases-- > 0) {
String line = scan.nextLine();
boolean matchFound = false;
Pattern r = Pattern.compile("<(.+)>([^<]+)</\1>");
Matcher m = r.matcher(line);
while (m.find()) {
matchFound = true;
if (!matchFound) {

Tags: HackerRank Online Judge Solution, HackerRank OJ Solution list, HackerRank Problems Solution, HackerRank solver, HackerRank all problem solution list, HackerRank solution in java, Hackerrank Java Solution, Hackerrank – Java Solution – Tag Content Extractor Solution, Hackerrank Online Judge Solution, Hackerrank – Java Solutions,

By Maniruzzaman Akash

Maniruzzaman Akash is a freelance web developer with most popular Laravel PHP frameork and Vue JS

Leave a Reply

Your email address will not be published. Required fields are marked *