{"id":15701069,"url":"https://github.com/burnett01/kotlin-expression-builder","last_synced_at":"2025-10-14T15:31:45.563Z","repository":{"id":21278553,"uuid":"92094420","full_name":"Burnett01/kotlin-expression-builder","owner":"Burnett01","description":"A regular expression (REGEX) class and builder (DSL), written in Kotlin.","archived":true,"fork":false,"pushed_at":"2023-02-06T09:06:52.000Z","size":174,"stargazers_count":8,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-11T23:51:41.102Z","etag":null,"topics":["builder","dsl","expression","expressions","java","jvm","kotlin","package","regex","regular-expression"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Burnett01.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null}},"created_at":"2017-05-22T20:02:23.000Z","updated_at":"2025-08-30T22:39:24.000Z","dependencies_parsed_at":"2023-02-19T06:01:12.045Z","dependency_job_id":null,"html_url":"https://github.com/Burnett01/kotlin-expression-builder","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/Burnett01/kotlin-expression-builder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Burnett01%2Fkotlin-expression-builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Burnett01%2Fkotlin-expression-builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Burnett01%2Fkotlin-expression-builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Burnett01%2Fkotlin-expression-builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Burnett01","download_url":"https://codeload.github.com/Burnett01/kotlin-expression-builder/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Burnett01%2Fkotlin-expression-builder/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279019322,"owners_count":26086711,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["builder","dsl","expression","expressions","java","jvm","kotlin","package","regex","regular-expression"],"created_at":"2024-10-03T19:59:16.612Z","updated_at":"2025-10-14T15:31:45.244Z","avatar_url":"https://github.com/Burnett01.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# kotlin-expression-builder\n\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/Burnett01/paypal-basket/master/LICENSE) \n[![](https://jitci.com/gh/Burnett01/kotlin-expression-builder/svg)](https://jitci.com/gh/Burnett01/kotlin-expression-builder)\n[![Build Status](https://travis-ci.com/Burnett01/kotlin-expression-builder.svg?branch=master)](https://travis-ci.com/Burnett01/kotlin-expression-builder) [![](https://jitpack.io/v/burnett01/kotlin-expression-builder.svg)](https://jitpack.io/#burnett01/kotlin-expression-builder)\n[![Scan with Detekt](https://github.com/Burnett01/kotlin-expression-builder/actions/workflows/detekt-analysis.yml/badge.svg)](https://github.com/Burnett01/kotlin-expression-builder/actions/workflows/detekt-analysis.yml)\n\n\u003cimg src=\"http://i.imgur.com/I0DES9A.png\" align=\"right\"/\u003e\n\nAn expression class and builder (DSL), written in Kotlin.\n\nThis package will assist you in writing and managing your regular expressions (Regex).\u003cbr\u003e\n\nI've been using this package in my [HAFAS-parser](https://github.com/Burnett01/hafas-parser) project, in order to simplify very complex regular expressions. Read more about it [on my blog](https://burnett01.blogspot.de/2017/06/developers-should-ease-code-readability.html)\n\nFeatures:\n  * Easy Regex management\n  * Available as a pure class (Expression)\n  * Available as a builder (ExpressionBuilder)\n  * Unit Tests\n\n---\n\n# Table of contents\n* [API Reference](#api-reference)\n  * [Expression](#expression)\n  * [ExpessionBuilder](#expressionbuilder)\n* [Usage (ExpressionBuilder)](#usage-expressionbuilder)\n* [Example](../master/contrib)\n* [Setup / Install](#setup-install)\n* [Build](#build)\n  * [Gradle](#gradle)\n* [Unit-Tests](#unit-tests)\n  * [Gradle](#gradle-1)\n* [CI](#ci)\n* [Contributing](#contributing)\n* [License](#license)\n\n---\n\n## API Reference\n\n### Expression:\n\n```kotlin\nclass Expression( op: Set\u003cRegexOption\u003e )\n\nfun markStart() = // '^'\nfun markEnd() =   // '$'\nfun markOr() =    // '|'\n\n/* Quantity (Q)\n * Q.ZERO_OR_ONE  = '?'\n * Q.ZERO_OR_MORE = '*'\n * Q.ONE_OR_MORE  = '+' \n */\nfun quantity(quant: Q = Q.ZERO_OR_ONE)\n\n/* Range\n * Delimiter '-' = [min-max] (default)\n * Delimiter ',' = {min,max}\n *\n * Example: range(0,9)     = [0-9]\n * Example: range(0,9,',') = {0,9}\n * Example: range('A','z') = A-z\n */\nfun range(min: Any, max: Any, delim: Char = '-')\n\nfun exact(times: Int) =      // {times,times}\nfun setChar(char: Char) =    // char\nfun setString(str: String) = // str\nfun setLiteral(lit: Char) =  // \\lit\nfun setDigit() =             // \\d\nfun setWord() =              // \\w\n\nfun startMatch() =           // [\nfun endMatch() =             // ]\n\n/* Start Capture Group\n * 0 = capture -\u003e (\n * 1 = no capture -\u003e (?:\n */\nfun startGroup(type: Int)   \nfun endGroup() = // )\n\nfun debug()\nfun compile(): Regex\n```\n\n### ExpressionBuilder:\n\n\u003e For documentation check above (Expression class) or demos/examples.\n\n```kotlin\n\nclass ExpressionBuilder { }\n\nfun start()\nfun end()\nfun or()\nfun quantity( quant: Q )\nfun exact( times: Int )\nfun range( min: Any, max: Any, delim: Char = '-' )\nfun literal( lit: Char )\nfun decimal( aggr: () -\u003e Unit = {} )\nfun string( str: String )\nfun char( char: Char )\nfun digit( aggr: () -\u003e Unit = {} )\nfun word( aggr: () -\u003e Unit = {} )\nfun whitespace()\nfun match( aggr: () -\u003e Unit = {} )\nfun nocapture( aggr: () -\u003e Unit )\nfun capture( aggr: () -\u003e Unit )\n\nfun expression( \n    entity: ExpressionBuilder.() -\u003e Unit,\n    options: Set\u003cRegexOption\u003e = emptySet()\n): Expression?\n\n// In addition to the functions above, \n// you can access every function of Expression class.\n```\n\n---\n\n## Usage (ExpressionBuilder):\n\n**Demo 1:**\n\n```kotlin\nimport com.github.burnett01.expression.*\n\nclass main {\n\n    val date: String = \"20.05.2017\"\n    val origExpr = Regex(\"(\\\\d{2}.\\\\d{2}.\\\\d{4})\")\n\n    val myExpr: Expression? = expression {\n        capture {\n            digit { exact(2) }\n            literal('.')\n            digit { exact(2) }\n            literal('.')\n            digit { exact(4) }\n        }\n    }\n\n    println(origExpr.find(date)?.value)\n    println(myExpr!!.compile().find(date)?.value)\n\n    myExpr.debug()\n\n}\n```\n\n**Demo 2:**\n\n```kotlin\nimport com.github.burnett01.expression.*\n\nclass main {\n\n    val txt: String = \"Hello catch me!%\"\n  \n    val myExpr: Expression? = expression({\n        capture {\n            string(\"Hello catch me!\")\n            literal('%')\n        }\n    })\n\n    println(myExpr!!.compile().find(txt)?.value)\n\n    myExpr.debug()\n\n}\n```\n\n**Passing options to Regex class:**\n\nAs of version 0.6, you may forward ``RegexOption``'s to the internal ``Regex`` class.\n\n```kotlin\nimport com.github.burnett01.expression.*\n\nclass main {\n\n    /* Available options (JVM):\n    IGNORE_CASE = Enables case-insensitive matching.\n    MULTILINE = Enables multiline mode.\n    LITERAL = Enables literal parsing of the pattern.\n    UNIX_LINES = In this mode, only the '\\n' is recognized as a line terminator.\n    COMMENTS = Permits whitespace and comments in pattern.\n    DOT_MATCHES_ALL = Enables the mode, when the expression . matches any character,\n    including a line terminator.\n    CANON_EQ = Enables equivalence by canonical decomposition.\n    */\n    val options: Set\u003cRegexOption\u003e = setOf(RegexOption.IGNORE_CASE)\n\n    val txt: String = \"HElLo CaTCh mE!%\"\n  \n    val myExpr: Expression? = expression({\n        capture {\n            string(\"Hello catch me!\")\n            literal('%')\n        }\n    }, options)\n\n    println(myExpr.compile().find(txt)?.value)\n\n    myExpr!!.debug()\n\n}\n```\n\n---\n\n## Setup / Install\n\nGradle dependency:\n\n```kotlin\nallprojects {\n    repositories {\n        maven { url 'https://jitpack.io' }\n    }\n}\n\ndependencies {\n    compile 'com.github.burnett01:kotlin-expression-builder:1.2.2'\n}\n```\n\nMaven dependency:\n\n```kotlin\n\u003crepositories\u003e\n    \u003crepository\u003e\n        \u003cid\u003ejitpack.io\u003c/id\u003e\n        \u003curl\u003ehttps://jitpack.io\u003c/url\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.Burnett01\u003c/groupId\u003e\n    \u003cartifactId\u003ekotlin-expression-builder\u003c/artifactId\u003e\n    \u003cversion\u003e1.2.2\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nCheck [here](https://jitpack.io/#Burnett01/kotlin-expression-builder/) for more.\n\n\n---\n\n## Build\n\n### Gradle\n\n```gradlew build```\n\n---\n\n## Unit-Tests\n\nThe testing-framework used by this package is [kotest](https://github.com/kotest/kotest).\n\nVarious tests are performed to make sure this package runs as smoothly as possible.\n\n\n* src/test/kotlin/com/github/burnett01/expression/expressionTest.kt\n\n    `28 tests` | [Source](../master/src/test/kotlin/com/github/burnett01/expression/expressionTest.kt)\n\n* src/test/kotlin/com/github/burnett01/expression/expression-builderTest.kt\n\n    `3 tests` | [Source](../master/src/test/kotlin/com/github/burnett01/expression/expression-builderTest.kt)\n\n### Gradle\n\n```gradlew test```\n\n---\n\n## CI\n\nTravis-CI, jitCI and detekt (code QL)\n\n---\n\n## Contributing\n\nYou're very welcome and free to contribute. Thank you.\n\n---\n\n## License\n\n[MIT](LICENSE)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fburnett01%2Fkotlin-expression-builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fburnett01%2Fkotlin-expression-builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fburnett01%2Fkotlin-expression-builder/lists"}