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.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Java
  3. Strings
  4. Tag Content Extractor
  5. Discussions

Tag Content Extractor

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 193 Discussions, By:

recency

Please Login in order to post a comment

  • ariannajono1
    4 weeks ago+ 0 comments

    I have a WordPress website called "LearnAboutCat," where I've created various categories or sections like "cat behavior," "cat care and training," "food and nutrition," and "cat facts." I'm worried that someone may extract my content from the website. Can you advise me on how I can prevent this from happening?

    0|
    Permalink
  • ngocthach_nt_a39
    1 month ago+ 1 comment
    Pattern pattern = Pattern.compile("<([^<>/]+)>([^<>]+)</(\\1)>");
    Matcher matcher = pattern.matcher(line);
    if(matcher.find()) {
    	System.out.println(matcher.group(2));
    	while(matcher.find()) {
    		System.out.println(matcher.group(2));
    	}
    } else {
    	System.out.println("None");
    }
    
    0|
    Permalink
  • slev1n_kelevrak1
    1 month ago+ 0 comments

    Working with content can be quite complicated indeed, and nowadays, it's essential because many industries depend on that. Even when it comes to OnlyFans, creators need to properly think about their content, but working with services like socedoagency promotion actually helps with that, making it a great source of additional income.

    -7|
    Permalink
  • yigitkucukcinar
    2 months ago+ 0 comments

    Java 8 Solution;

    import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;

    public class Solution{ private static final Pattern TAG_REGEX = Pattern.compile("<(.+)>([^<]+)"); public static void main(String[] args){

        Scanner in = new Scanner(System.in);
        int testCases = Integer.parseInt(in.nextLine());
        while(testCases>0){
            String line = in.nextLine();
            List<String> tagValues = getTagValues(line);
            for (String str : tagValues) {
                System.out.println(str);
            }
            testCases--;
        }
    }
    
    public static List<String> getTagValues(final String str) {
        final List<String> tagValues = new ArrayList<String>();
        final Matcher matcher = TAG_REGEX.matcher(str);
        if (matcher.find()) {
            matcher.reset();
                while (matcher.find()) {
                    tagValues.add(matcher.group(2));
                }
            //tagValues.add(matcher.group(2));
        } else {
            tagValues.add("None");
        }
        return tagValues;
    }
    

    }

    -2|
    Permalink
  • felipe_david_gu1
    2 months ago+ 0 comments
    public static void main(String[] args) {
    
        String regex = "<(.+)>([^<>]+)</(\\1)>";
        Pattern p = Pattern.compile(regex);
    
        Scanner in = new Scanner(System.in);
        int testCases = Integer.parseInt(in.nextLine());
        while (testCases > 0) {
            String line = in.nextLine();
    
            // Write your code here
            Matcher m = p.matcher(line);
    
            boolean bandera = true;
            while (m.find()) {
                System.out.println(m.group(2));
                bandera = false;
            }
    
            if (bandera) {
                System.out.println("None");
            }
    
            testCases--;
        }
    }
    
    -2|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy