Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static int getIndexOpeningTag(String tag, String text) {
        return getIndexOpeningTag(tag, text, 0);
    }

    private static int getIndexOpeningTag(String tag, String text, int start) {
        // consider whitespace?
        int idx = text.indexOf("<" + tag, start);
        if (idx == -1) {
            return -1;
        }
        char next = text.charAt(idx + 1 + tag.length());
        if ((next == '>') || Character.isWhitespace(next)) {
            return idx;
        } else {
            return getIndexOpeningTag(tag, text, idx + 1);
        }
    }
}