Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

public class Main {
    public static String getWithinTags(String matchString, String tag) {

        final Pattern pattern = Pattern.compile("<" + tag + ">(.+?)</" + tag + ">");
        final Matcher matcher = pattern.matcher(matchString);
        try {
            matcher.find();
            return matcher.group(1);
        } catch (Exception e) {
            System.out.println("An exception has occured within tags: " + e.toString());
            return "";
        }
    }
}