Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Common Regex Patterns #73

Open
8 tasks
mdjastrzebski opened this issue Mar 13, 2024 · 4 comments
Open
8 tasks

[Feature] Common Regex Patterns #73

mdjastrzebski opened this issue Mar 13, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@mdjastrzebski
Copy link
Member

mdjastrzebski commented Mar 13, 2024

Is your feature request related to a problem? Please describe.
Provide regex patterns for common use cases like:

  • URL
  • email
  • hashtags
  • hex color

Each pattern should be available in two versions:

  • validator - the goal of this pattern type is to validate that given string is a valid email, url, etc. This type of pattern should focus on RFC/standards compliance.
  • finder - the goal of this pattern type is to effectively find given types of patterns (e.g. emails, hashtags, etc) in a longer text. This pattern types aims to be 90% in order to improve efficiency.

Describe the solution you'd like
Patterns will be imported through ts-regex-builder/patterns import. See #72 for implementation of that part.

Whole library is and should remain tree-shakable, so that unused patterns (and features) are removed by bundlers in order to reduce bundle size.

Describe alternatives you've considered

  1. Providing pattens in examples/docs - this is an extra step and potentially hard to discover
  2. Do nothing - making correct version of certain patterns (e.g. URL) is hard, and we as the library providers can make user life easier here.

Checklist (for each pattern)

  • Implementation
  • Tests
  • API docs
  • README docs (if relevant)

CC: @PaulJPhilp

@mdjastrzebski mdjastrzebski added the enhancement New feature or request label Mar 13, 2024
@PaulJPhilp
Copy link
Contributor

I have a candidate for the URL patterns in my repo: . i am writing an article about using ts-regex-builder to build this regex. The point I am trying to make in the article is that this library allows you to write regular expressions like normal hygienic software. So, I break the URL pattern into sub-patterns (Scheme, Authority, ....). Can you take a look at what I've done before I put together a full PR and provide your feedback.

@mdjastrzebski
Copy link
Member Author

@PaulJPhilp awesome. Please send me some link to the code and I'll take a look.

@PaulJPhilp
Copy link
Contributor

Maciej:

Sorry for the delay. I ran into a bug (bug report to follow). Here is my repo with the partially completed URL pattern. Please let me know your feedback.

https://github.com/PaulJPhilp/ts-regex-builder

Thank you,
Paul

@mdjastrzebski
Copy link
Member Author

@PaulJPhilp you're definitely going in the good directions. The difficulty of the task, imo lies in the fact that URL is a complex pattern built from different smaller patterns, and it's a tedious work to get all of these right.

I've lefts some comments on the last commit: PaulJPhilp@0fdbf6c#diff-350009127029ecbdcc6940f99827bae2f3ece87b095a287c48db47ace9ef363dR43

BTW Pls create PR next, time, as it's make review and discussion happen in one, well defined place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants