{"id":42485179,"url":"https://github.com/mah0x211/lua-regex","last_synced_at":"2026-01-28T11:26:30.781Z","repository":{"id":138843521,"uuid":"93024127","full_name":"mah0x211/lua-regex","owner":"mah0x211","description":"regular expression for lua","archived":false,"fork":false,"pushed_at":"2024-05-21T01:34:46.000Z","size":37,"stargazers_count":19,"open_issues_count":1,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-05-21T03:33:51.878Z","etag":null,"topics":["lua","pcre2","regex","regexp"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mah0x211.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-01T06:31:49.000Z","updated_at":"2024-05-21T01:34:49.000Z","dependencies_parsed_at":"2023-04-09T21:18:33.805Z","dependency_job_id":null,"html_url":"https://github.com/mah0x211/lua-regex","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/mah0x211/lua-regex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mah0x211%2Flua-regex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mah0x211%2Flua-regex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mah0x211%2Flua-regex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mah0x211%2Flua-regex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mah0x211","download_url":"https://codeload.github.com/mah0x211/lua-regex/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mah0x211%2Flua-regex/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28845086,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T10:53:21.605Z","status":"ssl_error","status_checked_at":"2026-01-28T10:53:20.789Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lua","pcre2","regex","regexp"],"created_at":"2026-01-28T11:26:29.517Z","updated_at":"2026-01-28T11:26:30.776Z","avatar_url":"https://github.com/mah0x211.png","language":"Lua","readme":"# lua-regex\n\n[![test](https://github.com/mah0x211/lua-regex/actions/workflows/test.yml/badge.svg)](https://github.com/mah0x211/lua-regex/actions/workflows/test.yml)\n[![codecov](https://codecov.io/gh/mah0x211/lua-regex/branch/master/graph/badge.svg)](https://codecov.io/gh/mah0x211/lua-regex)\n\n\nsimple regular expression module for lua.\n\n\n## Installation\n\n```sh\nluarocks install regex\n```\n\n\n***\n\n\n## re, err = regex.new( pattern [, flgs] )\n\ncreates a new regex object.\n\n**Parameters**\n\n- `pattern:string`: string containing expression to be compiled.\n- `flgs:string`: regular expression flags that can be combined with any of the following characters.\n    - `i`: Do caseless matching.\n    - `s`: `.` matches anything including NL.\n    - `m`: `^` and `$` match newlines within data.\n    - `u`: Treat pattern and subjects as UTF strings.\n    - `U`: Do not check the pattern for `UTF` valid.\n    - `x`: Ignore white space and `#` comments.\n    - `o`: compile-once mode that caching a compiled regex.\n    - `g`: global match.\n    - `j`: enable JIT compilation.\n\n**Returns**\n\n- `re:table`: regex object.\n- `err:string`: error message.\n\n**Example**\n\n```lua\nlocal regex = require('regex')\nlocal re, err = regex.new('a(b+)(c+)', 'i')\nif re then\n    local arr, err = re:match('ABBBCCC')\n    if arr then\n        print(arr[1]) -- 'ABBBCCC'\n        print(arr[2]) -- 'BBB'\n        print(arr[3]) -- 'CCC'\n    else\n        print(err)\n    end\nelse\n    print(err)\nend\n```\n\n\n\n## arr, err = regex:match( sbj [, offset] )\n\nmatches a compiled regular expression against a given subject string. It returns matched substrings.\n\n**Parameters**\n\n- `sbj:string`: the subject string.\n- `offset:number`: offset in the subject at which to start matching.\n\n**Returns**\n\n- `arr:table`: array of matched substrings.\n- `err:string`: error message.\n\n\n## arr, err = regex:matches( sbj [, offset] )\n\nalmost same as `match` method but it returns all matched substrings **except capture strings**.\n\n**Parameters**\n\n- `sbj:string`: the subject string.\n- `offset:number`: offset in the subject at which to start matching.\n\n**Returns**\n\n- `arr:table`: array of matched substrings.\n- `err:string`: error message.\n\n\n## arr, err = regex:indexof( sbj [, offset] )\n\nalmost same as `match` method but it returns offsets of matched substrings.\n\n**Parameters**\n\n- `sbj:string`: the subject string.\n- `offset:number`: offset in the subject at which to start matching.\n\n**Returns**\n\n- `arr:table`: array of offsets of matched substrings. 1st index is the start offset of matched substring, and 2nd index is the end offset of matched substring, and 3rd index is the start offset of 1st capture string, and 4th index is the end offset of 1st capture string, and so on.\n- `err:string`: error message.\n\n\n## arr, err = regex:indexesof( sbj [, offset] )\n\nalmost same as `match` method but it returns all offsets of matched substrings **except capture strings**.\n\n**Parameters**\n\n- `sbj:string`: the subject string.\n- `offset:number`: offset in the subject at which to start matching.\n\n**Returns**\n\n- `arr:table`: array of offsets of matched substrings. 1st index is the start offset of matched substring, and 2nd index is the end offset of matched substring, and so on.\n- `err:string`: error message.\n\n\n## ok, err = regex:test( sbj [, offset] )\n\nreturns true if there is a matched.\n\n**Parameters**\n\n- `sbj:string`: the subject string.\n- `offset:number`: offset in the subject at which to start matching.\n\n**Returns**\n\n- `ok:boolean`: true on matched.\n- `err:string`: error message.\n\n\n\n## Static Methods\n\n\n## arr, err = regex.match( sbj, pattern [, flgs [, offset]] )\n\nsame as the following code:\n\n```lua\nlocal re, err = regex.new( pattern, flgs )\nif re then\n    return re:match( sbj, offset )\nend\nreturn nil, err\n```\n\n\n## arr, err = regex.matches( sbj, pattern [, flgs [, offset]] )\n\nsame as the following code:\n\n```lua\nlocal re, err = regex.new( pattern, flgs )\nif re then\n    return re:matches( sbj, offset )\nend\nreturn nil, err\n```\n\n\n## arr, err = regex.indexof( sbj, pattern [, flgs [, offset]] )\n\nsame as the following code:\n\n```lua\nlocal re, err = regex.new( pattern, flgs )\nif re then\n    return re:indexof( sbj, offset )\nend\nreturn nil, err\n```\n\n\n## arr, err = regex.indexesof( sbj, pattern [, flgs [, offset]] )\n\nsame as the following code:\n\n```lua\nlocal re, err = regex.new( pattern, flgs )\nif re then\n    return re:indexesof( sbj, offset )\nend\nreturn nil, err\n```\n\n\n## ok, err = regex.test( sbj, pattern [, flgs [, offset]] )\n\nsame as the following code:\n\n```lua\nlocal re, err = regex.new( pattern, flgs )\nif re then\n    return re:test( sbj, offset )\nend\nreturn nil, err\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmah0x211%2Flua-regex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmah0x211%2Flua-regex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmah0x211%2Flua-regex/lists"}