#!/usr/bin/luajit local re = require 're' local pat = re.compile([[ str <- {~ (bug / .)* ~} !. num <- { %d+ } bug <- (("bgo#" num) -> BGO) / (("bko#" num) -> BKO) / (("bmo#" num) -> BMO) / (("boo#" num) -> BOO) / (("bsc#" num) -> BSC) / (("gh#" { (!"#" .)+ } "#" { %w+ }) -> GH) / (("lp#" num) -> LP) / (("rh#" num) -> RH) ]],{ BGO = "http://bugzilla.gnome.org/show_bug.cgi?id=%1", BKO = "http://bugzilla.kernel.org/show_bug.cgi?id=%1", BMO = "http://bugzilla.mozilla.org/show_bug.cgi?id=%1", BOO = "http://bugzilla.opensuse.org/show_bug.cgi?id=%1", BSC = "http://bugzilla.suse.com/show_bug.cgi?id=%1", GH = "https://github.com/%1/issues/%2", LP = "https://launchpad.net/bugs/%1", RH = "http://bugzilla.redhat.com/show_bug.cgi?id=%1" }); print(pat:match("gh#python/cpython#123")) print(pat:match("lp#123456")) print(pat:match("bramboříček"))