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.*;

public class Main {
    public static final Pattern regex_ws = Pattern.compile("\\s+"), regex_csv = Pattern.compile("\\s*(,\\s*)+"),
            regex_norm = Pattern.compile("[^a-z_0-9\\Q-_+,.\\E]+"), regex_path = Pattern.compile("[^^]/+");

    public static String normalize(String s) {
        if (s == null)
            return "";

        s = s.toLowerCase();
        s = regex_norm.matcher(s).replaceAll(" ").trim();
        s = regex_ws.matcher(s).replaceAll("_");

        return s;
    }
}