{"id":24954897,"url":"https://github.com/simy4/coregex","last_synced_at":"2026-05-24T02:03:59.818Z","repository":{"id":37017949,"uuid":"349282997","full_name":"SimY4/coregex","owner":"SimY4","description":"A handy utility for generating strings that match given regular expression criteria.","archived":false,"fork":false,"pushed_at":"2025-01-30T10:46:10.000Z","size":578,"stargazers_count":3,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-30T11:30:39.746Z","etag":null,"topics":["jqwik","junit-quickcheck","regex","regex-match","regex-pattern","regexp","scalacheck","scalacheck-gen","scalacheck-generators","vavr-test"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SimY4.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2021-03-19T02:58:30.000Z","updated_at":"2025-01-30T10:46:13.000Z","dependencies_parsed_at":"2023-10-29T02:23:02.305Z","dependency_job_id":"f7f3de56-58ce-41a8-94cb-da772b47052b","html_url":"https://github.com/SimY4/coregex","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SimY4%2Fcoregex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SimY4%2Fcoregex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SimY4%2Fcoregex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SimY4%2Fcoregex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SimY4","download_url":"https://codeload.github.com/SimY4/coregex/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236892817,"owners_count":19221241,"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","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":["jqwik","junit-quickcheck","regex","regex-match","regex-pattern","regexp","scalacheck","scalacheck-gen","scalacheck-generators","vavr-test"],"created_at":"2025-02-03T05:17:32.111Z","updated_at":"2026-05-24T02:03:59.802Z","avatar_url":"https://github.com/SimY4.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# coregex\n[![Build Status](https://github.com/SimY4/coregex/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/SimY4/coregex/actions?query=workflow%3A\"Build+and+Test\")\n[![codecov](https://codecov.io/gh/SimY4/coregex/branch/main/graph/badge.svg)](https://codecov.io/gh/SimY4/coregex)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.github.simy4.coregex/coregex-core.svg)](https://search.maven.org/search?q=g:com.github.simy4.coregex)\n[![Javadocs](http://www.javadoc.io/badge/com.github.simy4.coregex/coregex-core.svg)](http://www.javadoc.io/doc/com.github.simy4.coregex/coregex-core)\n\nA handy utility for generating strings that match given regular expression criteria.\n\n# Supported generators\n\n- [functionaljava-quickcheck](https://github.com/functionaljava/functionaljava) \n- [hedgehog](https://hedgehogqa.github.io/scala-hedgehog/)\n- [jetCheck](https://github.com/JetBrains/jetCheck)\n- [Jqwik](https://jqwik.net/) \n- [JUnit Quickcheck](https://pholser.github.io/junit-quickcheck)\n- [Kotest](https://kotest.io/)\n- [scalacheck](https://scalacheck.org/)\n- [vavr-test](https://github.com/vavr-io/vavr-test)\n- [zio-test](https://zio.dev/reference/test/)\n\n# Usage\n\nYou can use this library directly by compiling an instance of coregex from any given regular expression pattern:\n\n```java\nvar pattern = Pattern.compile(\"[a-zA-Z]{3}\");\n\nvar coregex = Coregex.from(pattern);\n```\n\nHaving an instance of coregex, you can ask it to generate a string matching original regular expression. At any given time\nthis should be true:\n\n```java\nvar seed = ThreadLocalRandom.current().nextLong();\n\nassert pattern.matcher(coregex.generate(seed)).matches();\n```\n\nGiven the library is primarily intended to be used in property based testing, it comes with a set of integrations for popular\nproperty based testing frameworks.\n\n## Functionaljava Quickcheck\nInclude the following dependency into your project:\n\n```groovy\ntestImplementation \"com.github.simy4.coregex:coregex-functionaljava-quickcheck\"\n```\n\nUse the provided `CoregexArbirary` class to generate a string that would match the regular expression predicate:\n\n```java\n@RunWith(PropertyTestRunner.class)\npublic class MyTest {\n  private static final Pattern PATTERN = Pattern.compile(\"[a-zA-Z]{3}\");\n\n  public Property myProperty() {\n    return property(CoregexArbitrary.gen(PATTERN), CoregexArbitrary.shrink(PATTERN), str -\u003e prop(3 == str.length()));\n  }\n}\n```\n\n## hedgehog-scala\nInclude the following dependency into your project:\n\n```scala\nlibraryDependencies ++= Seq(\"com.github.simy4.coregex\" %% \"coregex-hedgehog\" % Test)\n```\n\nUse the provided `CoregexGen` class to generate a string that would match the regular expression predicate:\n\n```scala\nobject MySpec extends Properties {\n  def tests: List[Test] = List(\n    property(\"my property\", myProperty),\n  )\n\n  def myProperty: Property = for {\n    str \u003c- CoregexGen.fromRegex(\"[a-zA-Z]{3}\".r).forAll\n  } yield Result.assert(str.length ==== 3)\n}\n```\n\n## jetCheck\nInclude the following dependency into your project:\n\n```groovy\ntestImplementation \"com.github.simy4.coregex:coregex-jetCheck\"\n```\n\nUse the provided `CoregexGenerator` class to generate a string that would match the regular expression predicate:\n\n```java\nPropertyChecker.forAll(CoregexGenerator.of(\"[a-zA-Z]{3}\"), str -\u003e 3 == str.length());\n```\n\n## Jqwik\nInclude the following dependency into your project:\n\n```groovy\ntestImplementation \"com.github.simy4.coregex:coregex-jqwik\"\n```\n\nUse the provided `Regex` annotation to generate a string that would match the regular expression predicate:\n\n```java\nclass MyTest {\n  @Property\n  void myProperty(@ForAll @Regex(\"[a-zA-Z]{3}\") String str) {\n    assertThat(str).hasLength(3);\n  }\n}\n```\n\n## JUnit Quickcheck\nInclude the following dependency into your project:\n\n```groovy\ntestImplementation \"com.github.simy4.coregex:coregex-junit-quickcheck\"\n```\n\nUse the provided `Regex` annotation to generate a string that would match the regular expression predicate:\n\n```java\n@RunWith(JUnitQuickcheck.class)\npublic class MyTest {\n  @Property\n  public void myProperty(@Regex(\"[a-zA-Z]{3}\") String str) {\n    assertThat(str).hasLength(3);\n  }\n}\n```\n\n## Kotest\nInclude the following dependency into your project:\n\n```groovy\ntestImplementation \"com.github.simy4.coregex:coregex-kotest\"\n```\n\nUse the provided `CoregexArbirary` class to generate a string that would match the regular expression predicate:\n\n```kotlin\nclass MyTest : DescribeSpec({\n  describe(\"my property\") {\n    it(\"should hold\") {\n      checkAll(CoregexArbitrary.of(\"[a-zA-Z]{3}\")) { str -\u003e\n        str.length shouldBe 3\n      }\n    }\n  }\n})\n```\n\n## scalacheck\nInclude the following dependency into your project:\n\n```scala\nlibraryDependencies ++= Seq(\"com.github.simy4.coregex\" %% \"coregex-scalacheck\" % Test)\n```\n\nUse the provided `CoregexInstances` trait to constrain string arbitraries:\n\n```scala\nobject MySpecification extends Properties(\"MySpecification\") with CoregexInstances {\n  property(\"my property\") = forAll { (str: StringMatching[\"[a-zA-Z]{3}\"]) =\u003e\n    3 == str.length  \n  }\n}\n```\n\n## vavr test\nInclude the following dependency into your project:\n\n```groovy\ntestImplementation \"com.github.simy4.coregex:coregex-vavr-test\"\n```\n\nUse the provided `CoregexArbirary` class to generate a string that would match the regular expression predicate:\n\n```java\nProperty.def(\"my property\")\n    .forAll(CoregexArbitrary.of(\"[a-zA-Z]{3}\"))\n    .suchThat(str -\u003e 3 == str.length())\n    .check();\n```\n\n## ZIO test\nInclude the following dependency into your project:\n\n```scala\nlibraryDependencies ++= Seq(\"com.github.simy4.coregex\" %% \"coregex-zio-test\" % Test)\n```\n\nUse the provided `CoregexGen` class to generate a string that would match the regular expression predicate:\n\n```scala\nobject MySpec extends ZIOSpecDefault {\n  def spec = suite(\"my spec\")(\n    test(\"my property\") {\n      check(CoregexGen.from(Pattern.compile(\"[a-zA-Z]{3}\"))) { str =\u003e \n        assertTrue(str.length == 3)\n      }\n    }\n  )\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimy4%2Fcoregex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimy4%2Fcoregex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimy4%2Fcoregex/lists"}