unjs / magic-regexp

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

Home Page:https://regexp.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

feat: more predefined 'pieces' of regexps

danielroe opened this issue Β· comments

πŸ†’ 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

#48

πŸ” Alternatives you've considered

No response

ℹ️ Additional info

No response

@danielroe I have some time this month to contribute, so I plan to work on adding some predefined pieces of regexps.
I'm thinking of the following to start:

  • IPv4
  • IPv6
  • HTTP(S) URLs
  • Phone Numbers
  • Basic email validation
    • As mentioned in #48 , full validation is quite tricky

Usage

I think usage will look something like this:

import { ipv4 } from 'magic-regex/predefined'
  • @danielroe Any other ideas and a better module name would be greatly appreciated.

  • If anyone else has already started working on this, please let me know so we don't duplicate efforts.

P.S. I figured I'd mention this here: I use Python quite a bit, and I like the API of this package. So if time permits, I might make a python package with a similar API to magic-regex - obviously without the compile-time type hinting magic πŸ˜†.

That sounds great to me. And let me know when you've got your Python package up so I can link to it...