Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    public static String getProjectByUrl(String url) {
        Pattern pattern = Pattern.compile("https://(\\p{Ll}+).(.*)", Pattern.CASE_INSENSITIVE);
        Matcher matcher = pattern.matcher(url);
        if (!matcher.matches())
            throw new IllegalArgumentException("Regex fail. not matched. Url: " + url);

        return matcher.group(1);
    }
}