Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

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

public class Main {
    /**
     * 
     * @param tagName
     * @param content
     * @param fromIndex
     * @return
     */
    public static int findTagBegin(String tagName, CharSequence content, int fromIndex) {
        Pattern PTN_TAG_BEGIN = Pattern.compile("<" + tagName + "[\\s>]");
        Matcher matcher = PTN_TAG_BEGIN.matcher(content);
        if (matcher.find(fromIndex)) {
            return matcher.start();
        } else {
            return -1;
        }
    }
}