A compiled-away, type-safe, readable RegExp alternative

Overview

🦄 magic-regexp

npm version npm downloads Github Actions Codecov LGTM

A compiled-away, type-safe, readable RegExp alternative

Features

  • Runtime is zero-dependency and ultra-minimal
  • Ships with transform to compile to pure RegExp
  • Automatically typed capture groups
  • Natural language syntax
  • Generated RegExp displays on hover

📖  Read more

💻 Development

  • Clone this repository
  • Enable Corepack using corepack enable (use npm i -g corepack for Node.js < 16.10)
  • Install dependencies using pnpm install
  • Run interactive tests using pnpm dev

Similar packages

License

Made with ❤️

Published under MIT License.

Comments
  • feat: default to non-capture, add `grouped` and `groupedAs`

    feat: default to non-capture, add `grouped` and `groupedAs`

    last updated: 2022/8/17

    1. Update all creation and chaining helper inputs with anonymous capturing group syntax to non-capturing group by default.

    updated inputs:

    • creation inputs: anyOf, maybe, oneOrMore
    • chaining inputs: or, times(.between/atLeast/any), optionally
    1. Add chaining input helper grouped to opt-in/capture anonymous group.

    2. Add chaining input helper groupedAs to capture named group, same functionality as original as. and make as as an alias to groupedAs

    Usage

    // chaining with `.grouped`
    const defulatToNonCapture = anyOf('foo', 'bar') // Input<"(?:foo|bar)", never>
    const capture = anyOf('foo', 'bar').grouped() // Input<"(foo|bar)", never>
    
    const group = exactly('foo').times.between(2,5).grouped() // Input<"(foo){2,5}", never>
    
    • [x] add/update tests
    • [x] update docs
    • [x] finalize naming
    opened by didavid61202 7
  • fix: can't import transform in vite project without `type: module`

    fix: can't import transform in vite project without `type: module`

    🐛 The bug

    When I try to use magic-regexp in a Laravel + Vite project I get the following errors:

    Error [ERR_REQUIRE_ESM]: require() of ES Module /home/hassan/project/node_modules/.pnpm/[email protected][email protected]/node_modules/magic-regexp/dist/transform.mjs not supported.
    

    🛠️ To reproduce

    You can easily reproduce by following these steps:

    laraven new
    npx @preset/cli apply laravel:inertia
    php artisan serve
    npm run dev
    

    When you add the vite plugin, you will see the dev command will fail with error.

    🌈 Expected behaviour

    I expect it to work based on the project readme instructions and code examples.

    ℹ️ Additional context

    No response

    bug transform 
    opened by HassanZahirnia 7
  • feat: implement `letter.lowercase` and `letter.uppercase`

    feat: implement `letter.lowercase` and `letter.uppercase`

    Pretty trivial implementation!

    However, something is wonky in the changes to the typings tests I introduced in c2200a478fbceb25fcd88f274e064ab7068c9acb... The tests were broken by introducing lowercase and uppercase properties to letter, and when I tried reproducing a minimal example of it on typescriptlang.org, of course there, an Asdf<T> & { yes: 'no' } does extend Asdf<any>. I couldn't put my finger on what the fix should be.

    There might be a better way to handle them through savvy typing of the extractRegExp function, but I couldn't figure it out myself. 🙇‍♀️

    Resolves #37.

    opened by ccjmne 6
  • feat: Documentation

    feat: Documentation

    🆒 Your use case

    creating project documentation, documentation even at the beginning of the project is important for more people to test and give more ideas and get feedback from the community.

    🆕 The solution you'd like

    Vitepress, is powerful and can be easily implemented.

    🔍 Alternatives you've considered

    No response

    ℹ️ Additional info

    No response

    enhancement 
    opened by Muurilo 6
  • fix: update interface `Input` type parameter to contravariant type

    fix: update interface `Input` type parameter to contravariant type

    Updates

    1. Add in contravariant annotation to type parameter V of Input type:
    interface Input<
    -  V extends string,
    +  in V extends string,
      G extends string = never,
      C extends (string | undefined)[] = [] > { ... }
    
    1. Refactor InputSource to make Input accept any V type as it is set as contravariant type:
    - export type InputSource<S extends string = never, T extends string = never> = S | Input<S, T>
    + export type InputSource<S extends string = string, T extends string = never> = S | Input<any, T>
    
    1. Update/refactor IfUnwrapped type's all parameters to extends string instead of Input (makes usage more concise)
    - any: () => IfUnwrapped<V, Input<`(?:${V})*`, G>, Input<`${V}*`, G, C>>
    + any: () => Input<IfUnwrapped<V, `(?:${V})*`, `${V}*`>, G, C>
    
    1. fix ts comments for and and times chaining Input helpers

    Note

    This PR should resolve the type inferencing issue (using extractRegExp helper or directly using createRegExp) when implementing new letter.lowercase and letter.uppercase helper inputs in PR #77 and any future implementations of similar input helpers design to be accessed by `dot notation.

    opened by didavid61202 4
  • chore(deps): update devdependency nuxt to v3.0.0

    chore(deps): update devdependency nuxt to v3.0.0

    Mend Renovate

    This PR contains the following updates:

    | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | nuxt | 3.0.0-rc.12 -> 3.0.0 | age | adoption | passing | confidence |


    Release Notes

    nuxt/framework

    v3.0.0: Nuxt 3.0 stable

    Compare Source

    Official Release Announcenment

    💬 Release Discussion

    📝 Changelog

    Check out v3.0.0-rc.14 for other recent changes.

    🩹 Fixes
    • nuxt: Removed auto imports (#​9045)
    • schema: Initialise runtimeConfig.public with empty object (#​9050)
    • cli: Upgrade with latest tag (#​9060)
    • nuxt: Allow union type arguments for useAsyncData (#​9061)
    📖 Documentation
    • New website design (#​9007)
    • Update website theme version (819deb89)
    • Minor style improvements (9ab069b2)
    • Update website-theme (780b17b1)
    • Add warning about definePageMeta issues with transitions and NuxtLoadingIndicator (#​9055)
    • Add missing agencies (#​9059)
    🏡 Chore
    ❤️ Contributors

    v3.0.0-rc.14

    Compare Source

    Note This is the last release candidate for Nuxt v3! Are you ready? 👀

    👉 Release Discussion

    Changelog

    compare changes

    ⚠️ Breaking Changes
    • cli: Setup nuxt globally with nuxt test (#​4578)
    • nuxt: Only add $f fetch prefix to auto-keys (#​8852)
    • test-utils: Use vitest/node subpath export (#​8815)
    • nuxt: Remove initialCache option (#​8885)
    • nuxt: Enable payload extraction only for nuxi generate (#​9018)
    • nuxt: Include request url and params in useFetch key (#​6632)
    • nuxt: Fix typo for NuxtRenderHTMLContext.bodyPrepend (#​8712) (#​8704)
    • nuxt: Remove support for 404.vue shorthand (#​8809)
    • kit: Remove support for module container (#​9010)
    • nuxt: Move head option support into defineNuxtComponent (#​8901)
    • Remove deprecated api (#​9029) - Remove PrivateRuntimeConfig interface support - Remove autoImports option - Remove autoImports:extend hook support - Remove deprecated addAutoImport and addAutoImport utilities (use addImports and addImportsDir) - Remove defer option for useAsyncData - Remove support for installModule(nuxt, nuxtModule) - Remove support for module defenition as function - Remove support for name in module definition (use meta.name) - Remove deprecated throwError (use showError) - Remove deprecated useActiveRoute (use useRoute) - Remove deprecated NuxtConfig and defineNuxtConfig imports from nuxt (import from nuxt/config) - Remove deprecated <Script> component (use useHead) - Remove deprecated RouterConfigOptions interface (use RouterConfigSerializable) - Remove deprecated fileName for template options (use filename) - Remove deprecated <NuxtNestedPage> and <NuxtChild> components - Remove deprecated buildModules config - Remove deprecated privateRuntimeConfig and publicRuntimeConfig options - Remove deprecated imports.presets[].name (use presets.imports instead)
    🚀 Enhancements
    • nuxt: Add isExternal to <NuxtLink> slot props (#​8800)
    • nuxt: Auto-import utils/ directory (#​8817)
    • cli: Wrap and normalize all console outputs (#​8846)
    • nuxt: Allow customizing root id and tag (#​8883)
    • nuxt: Add onBeforeRouteLeave and onBeforeRouteUpdate composables (#​8889)
    • cli: ⚠️ Setup nuxt globally with nuxt test (#​4578)
    • cli: Auto-generate .npmrc and setting for pnpm (#​7407)
    • nuxt, schema: Migrate to @​vueuse/head v1 (#​8975)
    🩹 Fixes
    • nuxt: Check if global transitions are activated for scroll behavior (#​8700)
    • nuxt: Allow cookies to be set to null to unset them (#​8769)
    • nuxt: Add catchall paths to prerender list (#​8782)
    • schema: Add declarations to ignore list (#​8787)
    • ssr: Ensure useRequestHeaders are case-insensitive (#​8805)
    • nuxt: Do not render page if we are throwing error (#​8821)
    • nuxt: Swallow issues with query selectors (#​8843)
    • nuxt: ⚠️ Only add $f fetch prefix to auto-keys (#​8852)
    • test-utils: Detect project root using nuxt.config with .mjs and .cjs extensions (#​8855)
    • cli: Exclude dist from type checking (#​8848)
    • test-utils: ⚠️ Use vitest/node subpath export (#​8815)
    • nuxt: Detect non-functional imports within page meta (#​8881)
    • nuxt: Preserve render errors (#​8884)
    • nuxt: ⚠️ Remove initialCache option (#​8885)
    • nuxt: Use app.baseURL when fetching error page on server (#​8888)
    • nuxt: Avoid passing attrs to default slot for <ClientOnly> component (#​8921)
    • vite: Add extend layers to fs.allow (#​9006)
    • nuxt: Include layers in esbuild transform (#​9014)
    • kit: Add external module to transpile (#​8963)
    • nuxt: ⚠️ Enable payload extraction only for nuxi generate (#​9018)
    • nuxt: ⚠️ Include request url and params in useFetch key (#​6632)
    • nuxt: Improve hmr for pages macros (#​8940)
    💅 Refactors
    • nuxt: ⚠️ Fix typo for NuxtRenderHTMLContext.bodyPrepend (#​8712)
    • nuxt: ⚠️ Fix typo for NuxtRenderHTMLContext.bodyPrepend (#​8704)
    • nuxt: ⚠️ Remove support for 404.vue shorthand (#​8809)
    • nuxt: Explicitly import app in nuxt-root (#​8729)
    • kit: ⚠️ Remove support for module container (#​9010)
    • Update unjs dependencies to stable v1 (#​9011)
    • nuxt: ⚠️ Move head option support into defineNuxtComponent (#​8901)
    • ⚠️ Remove deprecated api (#​9029)
    📖 Documentation
    • Update 2.nuxt-page.md (#​8761)
    • Update roadmap for november (#​8766)
    • Use update import for defineLazyEventHandler (#​8767)
    • Remove stability-edge (507f444c)
    • deployment: Remove usage of custom icons (8e4068b7)
    • Improve examples content (1582f8ec)
    • api: Add useRequestHeaders composable example (#​8833)
    • Add entry for extendPages (#​8860)
    • api: Add refreshNuxtData util examples (#​8845)
    • Get event before running async function (#​8861)
    • api: Add useHydration composable (#​8768)
    • Add query option with example for useFetch (#​8719)
    • Add initial documentation for router composables (#​8895)
    • Add tls option to redis example (#​8900)
    • Fix syntax errors in server storage example (#​8906)
    • Fix typo (#​8970)
    • api: Add spaces to avoid breaking mobile layout (#​8967)
    • Typo in available (#​8966)
    • Add a bit more detail in the definePageMeta warning to specify it needs to be in a page (#​8923)
    • Match the open graph protocol markup (#​8959)
    • Fix typos (#​8976)
    ❤️ Contributors

    v3.0.0-rc.13

    Compare Source

    👉 Release discussion

    ⭐ What is New?
    🔰 Security Fixes

    This release contains multiple security related fixes #​8675, #​8674 and #​8673 reported via huntr.dev platform by OhB00.

    We recommend you upgrade to the latest version as soon as possible.

    If you encounter "The request URL ... is outside of Vite service allow list" issue, try adding path to vite.server.fs.allow in nuxt.config. read more.

    🚀 Performance Improvements

    Using a new method to extract definePageMeta improves vite performance and makes lazy compilation of pages possible (#​8536).

    💯 Strict Config Schema and Types

    We have cleaned up the configuration schema (#​8487) so that you no longer would be confused with Nuxt 2 options and also can quickly notice any typos in nuxt.config file.

    Typescript strict mode is also enabled by default with this release as best practice. (#​8667)

    🚇 Nitro Development Server Proxy

    Using nitro.devProxy option you can now configure proxies for the development server. (learn more)

    Changelog

    compare changes

    ⚠️ Breaking Changes
    • nuxt: ⚠️ Use parser to generate page metadata (#​8536)
    • schema: ⚠️ Use strict typescript mode by default (#​8667)
    • test-utils: ⚠️ Update vitest args (#​8325)
    • schema: ⚠️ Disable app.pageTransition and app.layoutTransition by default (#​8436)
    • nuxt: ⚠️ Cleanup schema and split nuxt 2 types (#​8487)
    🚀 Enhancements
    • nuxt: Default router scroll behavior (#​3851)
    • nuxt: Make useFetch options reactive (#​8374)
    • kit: Add updateTemplates utility (#​8413)
    • nuxt: Add dev warnings when setPageLayout is used incorrectly (#​8464)
    • Add <devOnly> component (#​7950)
    • nuxt: Allow setting name and path for a route in definePageMeta (#​8633)
    • kit: Add addServerPlugin utility (#​8635)
    • kit, nuxt: Support prerender:routes and addPrerenderRoutes (#​8670)
    🩹 Fixes
    • nuxt: Don't use or assignment (#​8299)
    • nuxt: Pass original request headers to the error page (#​7340)
    • nuxt: Scroll to top on dynamic routes with different params (#​8327)
    • nuxt: Router defaults overwrite custom options always (#​8334)
    • cli: Update analzye main handler (#​8339)
    • nuxt: RouterBehavior comparison for hash block (#​8383)
    • nuxt: Don't load payloads for external urls (#​8370)
    • vite: Invalidate virtual modules with vite-node (#​8389)
    • nuxt: Avoid directly importing vue-router inside <NuxtLayout> (#​8421)
    • webpack: Print build errors (#​8388)
    • kit: Use pathe to resolve aliases (#​8453)
    • test-utils: Override NITRO_PORT as well (#​8458)
    • nuxt: Call data refresh hook in parallel (#​8470)
    • nuxt: Allow responding with custom headers from error.vue (#​8469)
    • schema: Disable early hints by default (#​8486)
    • kit: Don't require nuxt context when resolving path (#​8504)
    • nuxt, nuxi: Improve pages creation and removal DX (#​8502)
    • nuxt: Add vue-router to optimized deps (#​8544)
    • vite: Handle all vite middleware routes (#​8601)
    • nuxt: Pass async-data errors through to client (#​8521)
    • nuxt: Check before appending comma in composable keys (#​8529)
    • nuxt: ⚠️ Use parser to generate page metadata (#​8536)
    • kit: Normalize handler paths (#​8626)
    • nuxt: Don't force prerender / if user doesn't have that route (#​8639)
    • nuxt: Do not inline global styles in html response (#​8666)
    • schema: ⚠️ Use strict typescript mode by default (#​8667)
    • nuxt: Disallow directly rendering error page (#​8673)
    • Resolve ids to support pnpm (#​8671)
    • vite: Enable fs strict mode (#​8674)
    • nuxt: Ensure payload url has no protocol (#​8675)
    💅 Refactors
    • test-utils: ⚠️ Update vitest args (#​8325)
    • schema: ⚠️ Disable app.pageTransition and app.layoutTransition by default (#​8436)
    • nuxt: ⚠️ Cleanup schema and split Nuxt 2 types (#​8487)
    📖 Documentation
    • Add route rules to concepts > rendering (#​8292)
    • Fix broken link (#​8319)
    • Fix link to documentation guide (#​8322)
    • Update website-theme to 0.1.7 (dbc2c8ce)
    • Add missing opening <NuxtLayout> tag in a code sample (#​8349)
    • Update links for external tools (#​8382)
    • Update for clarity and fix typos (#​8375)
    • Add missing app key for transitions (#​8385)
    • api: Add <ClientOnly> to API docs (#​8400)
    • Fix typo (#​8427)
    • Disable transitions by default as hotfix (#​8434)
    • Add note about runtime config serialization (#​8432)
    • Change required node version to be above 16.11 (#​8408)
    • Use LinkExample as block component (#​8459)
    • Add note about early hints and nginx (#​8485)
    • Updated bridge migration guide (#​8471)
    • Mention use case for <KeepAlive> in definePageMeta (#​8491)
    • Update stability edge banners (#​8498)
    • Generate docs for unversioned schema (#​8535)
    • Fix transition wording to include layouts (#​8600)
    • Add information about type checking to typescript.typeCheck config. (#​8632)
    📦 Build
    🏡 Chore
    • renovate: Ignore monorepo dependency upgrades (f934343b)
    • Upgrade vitest to 0.24 (#​6764)
    • nuxt: Add type for headers (#​8326)
    • examples: Add missing dependency and script for testing example (#​8457)
    • Reenable auto-upgrades for vueuse/head (#​8506)
    • Update nitropack to 0.6.1 (5a43e68e)
    ✅ Tests
    ❤️ Contributors
    • Adewale Adeyemi
    • Anthony Fu
    • Christian Burkhart
    • Clément Ollivier
    • Damian Głowala
    • Daniel Roe
    • David Stack
    • Dawid Stefanko
    • Dmitriy
    • Farnabaz
    • Joel
    • Joel Wenzel
    • Johann Schopplich
    • Johnson Chu
    • Josh Deltener
    • Julien Huang
    • Nils
    • Ondřej Misák
    • Pascal Sthamer
    • Pooya Parsa
    • Rajendra
    • Sacha STAFYNIAK
    • Sébastien Chopin
    • Zecka

    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Enabled.

    Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    dependencies chore 
    opened by renovate[bot] 3
  • ci: add codeql code scanning workflow

    ci: add codeql code scanning workflow

    Hi danielroe/magic-regexp!

    This is a one-off automatically generated pull request from LGTM.com :robot:. You might have heard that we’ve integrated LGTM’s underlying CodeQL analysis engine natively into GitHub. The result is GitHub code scanning!

    With LGTM fully integrated into code scanning, we are focused on improving CodeQL within the native GitHub code scanning experience. In order to take advantage of current and future improvements to our analysis capabilities, we suggest you enable code scanning on your repository. Please take a look at our blog post for more information.

    This pull request enables code scanning by adding an auto-generated codeql.yml workflow file for GitHub Actions to your repository — take a look! We tested it before opening this pull request, so all should be working :heavy_check_mark:. In fact, you might already have seen some alerts appear on this pull request!

    Where needed and if possible, we’ve adjusted the configuration to the needs of your particular repository. But of course, you should feel free to tweak it further! Check this page for detailed documentation.

    Questions? Check out the FAQ below!

    FAQ

    Click here to expand the FAQ section

    How often will the code scanning analysis run?

    By default, code scanning will trigger a scan with the CodeQL engine on the following events:

    • On every pull request — to flag up potential security problems for you to investigate before merging a PR.
    • On every push to your default branch and other protected branches — this keeps the analysis results on your repository’s Security tab up to date.
    • Once a week at a fixed time — to make sure you benefit from the latest updated security analysis even when no code was committed or PRs were opened.

    What will this cost?

    Nothing! The CodeQL engine will run inside GitHub Actions, making use of your unlimited free compute minutes for public repositories.

    What types of problems does CodeQL find?

    The CodeQL engine that powers GitHub code scanning is the exact same engine that powers LGTM.com. The exact set of rules has been tweaked slightly, but you should see almost exactly the same types of alerts as you were used to on LGTM.com: we’ve enabled the security-and-quality query suite for you.

    How do I upgrade my CodeQL engine?

    No need! New versions of the CodeQL analysis are constantly deployed on GitHub.com; your repository will automatically benefit from the most recently released version.

    The analysis doesn’t seem to be working

    If you get an error in GitHub Actions that indicates that CodeQL wasn’t able to analyze your code, please follow the instructions here to debug the analysis.

    How do I disable LGTM.com?

    If you have LGTM’s automatic pull request analysis enabled, then you can follow these steps to disable the LGTM pull request analysis. You don’t actually need to remove your repository from LGTM.com; it will automatically be removed in the next few months as part of the deprecation of LGTM.com (more info here).

    Which source code hosting platforms does code scanning support?

    GitHub code scanning is deeply integrated within GitHub itself. If you’d like to scan source code that is hosted elsewhere, we suggest that you create a mirror of that code on GitHub.

    How do I know this PR is legitimate?

    This PR is filed by the official LGTM.com GitHub App, in line with the deprecation timeline that was announced on the official GitHub Blog. The proposed GitHub Action workflow uses the official open source GitHub CodeQL Action. If you have any other questions or concerns, please join the discussion here in the official GitHub community!

    I have another question / how do I get in touch?

    Please join the discussion here to ask further questions and send us suggestions!

    opened by lgtm-com[bot] 3
  • chore(deps): update all non-major dependencies

    chore(deps): update all non-major dependencies

    Mend Renovate

    This PR contains the following updates:

    | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | @vitest/coverage-c8 | ^0.22.1 -> ^0.23.2 | age | adoption | passing | confidence | | nuxt | ^3.0.0-rc.8 -> ^3.0.0-rc.10 | age | adoption | passing | confidence | | pnpm (source) | 7.9.5 -> 7.11.0 | age | adoption | passing | confidence | | vite (source) | ^3.0.9 -> ^3.1.1 | age | adoption | passing | confidence |


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Renovate will not automatically rebase this PR, because other commits have been found.

    👻 Immortal: This PR will be recreated if closed unmerged. Get config help if that's undesired.


    • [ ] If you want to rebase/retry this PR, click this checkbox. ⚠ Warning: custom changes will be lost.

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 3
  • chore(deps): update all non-major dependencies

    chore(deps): update all non-major dependencies

    Mend Renovate

    This PR contains the following updates:

    | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | mlly | ^0.5.10 -> ^0.5.12 | age | adoption | passing | confidence | | nuxt | ^3.0.0-rc.6 -> ^3.0.0-rc.8 | age | adoption | passing | confidence | | vite | ^3.0.5 -> ^3.0.6 | age | adoption | passing | confidence |


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Renovate will not automatically rebase this PR, because other commits have been found.

    👻 Immortal: This PR will be recreated if closed unmerged. Get config help if that's undesired.


    • [ ] If you want to rebase/retry this PR, click this checkbox. ⚠ Warning: custom changes will be lost.

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 3
  • differentiate lowercase letter, uppercase letter, or combine them

    differentiate lowercase letter, uppercase letter, or combine them

    🆒 Your use case

    right now the function letter is include all the uppercase and lowercase letter, my use case is i only need the lowercase letter, and uppercase letter is prohibited.

    🔍 Alternatives you've considered

    No response

    ℹ️ Additional info

    No response

    enhancement 
    opened by zynth17 3
  • feat: add chained input `and.referenceToGroup`

    feat: add chained input `and.referenceToGroup`

    Add a chained input and.referenceToGroup (regex: \k<groupName>) to add a new pattern that references the previously captured groups using the group name.

    The argument of and.referenceToGroup (group name) have type safety by inferring from the Input type and should show autocomplete.

    Not sure if the naming is clear, align with other names and easy to understand? need suggestion!

    Usage

    import { createRegExp, word, oneOrMore } from 'magic-regexp'
    
    const RE = createRegExp(
      word
        .as('firstWord')
        .and(word.as('secondWord'))
        .and(oneOrMore(char))
        .and.referenceToGroup('secondWord')
        .and.referenceToGroup('firstWord')
    ) // /(?<firstWord>\w)(?<secondWord>\w)(.)+\k<secondWord>\k<firstWord>/
    
    assert.equal(RE.test('TEN<==O==>NET'), true)
    
    
    opened by didavid61202 3
  • performance testing

    performance testing

    with the amount of inference we're doing, it would be a great enhancement to add some kind of type performance test to ensure that end users' TS checkers or IDEs don't get slower. With metrics, we also will have a basis for making performance improvements.

    enhancement 
    opened by danielroe 0
  • `Predefined Input can not be assigned to InputSource` when using with TypeScript < 4.7

    `Predefined Input can not be assigned to InputSource` when using with TypeScript < 4.7

    I just installed magic-regexp via yarn add magic-regexp and tried the first example from https://regexp.dev/getting-started/examples

    Typescript does not like it though: Argument of type 'Input<"\\d", never>' is not assignable to parameter of type 'InputSource<string, never>'.

    The code can also be simplified even more: const regex = createRegExp(oneOrMore(digit));

    I have created a codesandbox for showcasing this: https://codesandbox.io/s/gracious-swartz-3sdfcs

    opened by tim3trick 6
  • Typing for String.replace callback function

    Typing for String.replace callback function

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_function_as_a_parameter

    Depends on strongly typing anonymous groups: https://github.com/danielroe/magic-regexp/issues/24

    enhancement 
    opened by danielroe 0
  • feat: Turn existing regex to this

    feat: Turn existing regex to this

    🆒 Your use case

    There are lot of regex being used in codebase. And if there is an easy way to put them in playground and get the equivalent of it in magic-regex - it will be awesome

    🆕 The solution you'd like

    There are lot of regex being used in codebase. And if there is an easy way to put them in playground and get the equivalent of it in magic-regex - it will be awesome

    🔍 Alternatives you've considered

    No response

    ℹ️ Additional info

    No response

    enhancement 
    opened by o1lab 0
  • feat: more predefined 'pieces' of regexps

    feat: more predefined 'pieces' of regexps

    🆒 Your use case

    Suggestion

    🆕 The solution you'd like

    You should add macroability and predefine some macros like http link, xml tag or i don't know maybe uk phone macros etc.

    https://twitter.com/senbanabakhele/status/1548715207194824706

    More examples:

    • US Phone Numbers
    • Email Validation

    https://github.com/danielroe/magic-regexp/discussions/48

    🔍 Alternatives you've considered

    No response

    ℹ️ Additional info

    No response

    enhancement 
    opened by danielroe 0
Releases(0.6.1)
A fun and functional way to write regular expressions (RegExp)

funexp A fun and functional way to write regular expressions (RegExp). FunExp is a useful tool for larger projects that depends on RegExp to do heavy

Matheus Giovani 2 Feb 7, 2022
100% type-safe query builder for node-postgres :: Generated types, call any function, tree-shakable, implicit type casts, and more

⚠️ This library is currently in alpha. Contributors wanted! tusken Postgres client from a galaxy far, far away. your database is the source-of-truth f

alloc 54 Dec 29, 2022
自动保持 GitHub 提交状态常绿 a commit every day, keep your girlfriend far away.

node-auto-green 自动保持 GitHub 提交状态常绿。 a commit a day keeps your girlfriend away. node-auto-green 是 auto-green 的 Node.js 版本。源自一个 issue Actions 被禁用,请问是否有腾

迷渡 24 Oct 11, 2022
Nest multiple blocks inside lists of any kind of list (ordered, unordered, no marker, etc), or do away with list markers and use it like a repeater!

Nest multiple blocks inside lists of any kind of list (ordered, unordered, no marker, etc), or do away with list markers and use it like a repeater!

Rani 15 Dec 26, 2022
📸 A command-line tool to generate code images of your local code right away from the terminal

?? rayli ?? A command-line tool to generate code images of your local code right away from the terminal Usage Commands Usage $ npm install -g rayli $

buidler's hub 45 Nov 4, 2022
Get started with GatsbyJS straight away without having to spend a whole day configuring your usual addons.

Gatsby Starter Infinite Get started with GatsbyJS straight away without having to spend a whole day configuring your usual addons. This starter includ

Matt Patterson 3 Jun 27, 2022
Demo for my talk "Stream Away the Wait" – a talk about making excellent pending experiences.

?? Stream Away the Wait When implementing the design of a user interface, we often finish before remembering that not everyone's running the app's ser

Kent C. Dodds 25 Nov 1, 2022
Minimal template engine with compiled output for JavaScript.

@fnando/seagull Minimal template engine with compiled output for JavaScript. Installation This package is available as a NPM package. To install it, u

Nando Vieira 5 Mar 1, 2022
AWS CDK compiled for web (and Node!)

cdk-web ?? DEMO ?? AWS CDK compiled for web (and Node!) cdk-web and aws-cdk-web are functionally identical packages on npm. read about the differences

Sepehr Laal 44 Dec 5, 2022
PDF.js compiled for node-less, serverless enviroments.

Pdf.mjs PDF.js custom-compiled for nodeless, serverless enviroments, like Deno Deploy and Cloudflare Workers. Rocking in under 700kb uncompressed. Usa

Brúnó Salomon 7 Apr 16, 2022
Remix sandbox repo for Rust compiled to WASM and to native N-API modules

Rust <-> Remix Sandbox Now with both native Rust and WASM versions! If you want to combine the Web Fundamentals & Modern UX of Remix together with the

Ben Wishovich 26 Dec 30, 2022
Solid, AssemblyScriptified and compiled to WebAssembly

solid-as Solid as _____! Solid, AssemblyScriptified and compiled to WebAssembly (very work in progress). Installation TODO Test npm i && npm test TODO

Joe Pea 4 Jul 19, 2022
A library of icons rendered purely in CSS and compiled using SASS.

Welcome to PureIcons.css: This is a library of icons rendered purely in CSS and compiled using SASSs. It is currently at 79 icons. More will be added

William Troup 2 Apr 27, 2021
Build type-safe web apps with PureScript.

PUX Build type-safe web applications with PureScript. Documentation | Examples | Chat Pux is a PureScript library for building web applications. Inter

Alex Mingoia 567 Jun 18, 2022
A zero-dependency, buildless, terse, and type-safe way to write HTML in JavaScript.

hdot A sensible way to write HTML in JavaScript. Type-safe. Helps you follow the HTML spec. Terse. Almost character for character with plain HTML. Bui

Will Martin 31 Oct 24, 2022
Type Safe Object Notation & Validation

tson Type Safe Object Notation & Validation ?? Work in Progress, not ready for production... Features ?? Functional ?? Immutable ✅ Well tested Why? Af

null 9 Aug 10, 2022
Cloudy is a set of constructs for the AWS Cloud Development Kit that aim to improve the DX by providing a faster and type-safe code environment.

cloudy-ts These packages aren't yet published on npm. This is still highly experimental. Need to figure out a few things before releasing the first ve

Cristian Pallarés 5 Nov 3, 2022
Zero runtime type-safe CSS in the same file as components

macaron comptime-css is now called macaron! macaron is a zero-runtime and type-safe CSS-in-JS library made with performance in mind Powered by vanilla

Mokshit Jain 205 Jan 4, 2023