Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

public class Main {
    public static String getEventOfExpression(String expression) {
        // pattern for events
        Pattern eventPattern = Pattern.compile("^[\\w\\W&&[^/\\[\\]]]+(\\[[\\w\\W&&[^\\[\\]]]+\\])?(/[\\w\\W]+)?$");
        Matcher eventMatcher = eventPattern.matcher(expression);
        if (eventMatcher.find() && (eventMatcher.group().length() == expression.length())) {
            StringTokenizer st = new StringTokenizer(expression, "[]/");
            return st.nextToken();
        }
        return null;
    }
}