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.HashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    private static HashMap<String, String> parseContent(String src) {
        HashMap<String, String> map = new HashMap<String, String>();
        String patternStr = "http://(.*)\\?chat_id=[-]?(\\d+)&chat_name=(.+)";

        Pattern p = Pattern.compile(patternStr);
        Matcher m = p.matcher(src);
        if (!m.find()) {
            return null;
        } else if (m.groupCount() == 3) {
            map.put("chat_id", m.group(2));
            map.put("chat_name", m.group(3));
            return map;
        }

        return null;
    }
}