純Haxe實現的正則表達式引擎:HxRE

jopen 10年前發布 | 19K 次閱讀 HxRE

HxRE是一個純Haxe實現的正則表達式引擎。

這個庫基于 libregex.

Haxe's macro facility is used to provide compile-time specialization of the regex virtual machine.

Usage

@:build(hxre.Specializer.build("(\\d{4})-(\\d{2})-(\\d{2})"))
class SpecialRegex extends hxre.NfaVM {}

class Main {
    public static function main() {
        // dynamic compiled regex
        var re = new hxre.Regex("(\\d{2}):(\\d{2})");
        trace(re.exec("2014-11-20T12:00Z"));

        // static compiled regex
        trace(SpecialRegex.regex.exec("Date: 2014-11-30"));

        // static regex is also able to create new instances
        var sre : hxre.Regex = new SpecialRegex();
        trace(sre.exec("2014-12-31T12:00Z"));
    }
}

項目主頁:http://www.baiduhome.net/lib/view/home/1416294104461

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!