blocks4j / reconf-server

Home of the ReConf Server Project
2 stars 2 forks source link

Specialization of properties through regexps #6

Closed dmutti closed 10 years ago

dmutti commented 10 years ago

http://groovy.codehaus.org/Regular+Expressions http://docs.ruby-lang.org/en/trunk/Regexp.html http://www.w3schools.com/js/js_regexp.asp

dmutti commented 10 years ago
    public static void main(String[] args) throws Exception {
        ScriptEngineManager factory = new ScriptEngineManager();
        ScriptEngine engine = factory.getEngineByName("JavaScript");
        engine.put("regexp", "/[a-zA-Z0-9]+/");
        engine.put("input", "a");
        engine.eval("var patt = eval(regexp); var result = patt.test(input);");
        System.out.println(engine.get("result"));
    }
dmutti commented 10 years ago

Done!