magic-regexp icon indicating copy to clipboard operation
magic-regexp copied to clipboard

feat: more predefined 'pieces' of regexps

Open danielroe opened this issue 3 years ago â€ĸ 2 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

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

🔍 Alternatives you've considered

No response

â„šī¸ Additional info

No response

danielroe avatar Jul 17 '22 17:07 danielroe

@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 😆.

xRSquared avatar Mar 01 '23 00:03 xRSquared

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

danielroe avatar Mar 01 '23 09:03 danielroe