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 getActionOfExpression(String expression) {
        // pattern for actions
        Pattern actionPattern = Pattern
                .compile("^([\\w\\W&&[^/\\[\\]]]+)?(\\[[\\w\\W&&[^\\[\\]]]+\\])?(/[\\w\\W]+)$");
        Matcher actionMatcher = actionPattern.matcher(expression);
        if (actionMatcher.find() && (actionMatcher.group().length() == expression.length())) {
            String action = expression.substring(expression.lastIndexOf("/") + 1);
            return action;
        }
        return null;
    }
}