Comments (10)
This is definitely a worthy enhancement. I think @didavid61202 might be working on this very thing (so let's wait to hear from him), but if not then contribution would be very welcome ❤️
from magic-regexp.
Yes, I've been working on a new type inferencing (fully parse, interpret, exact match, permutation all possible values) for string.match, string.replace, string.matchAll and string.replaceAll
Sounds awesome! 😀
Of course, if the other functions can also benefit of the inference, it's even better. I haven't worked yet with .replace
with this library, but this sounds really game changing. It makes it so much easier to work with string manipulation of all kind.
The inference looks great so far. Tell me if I can help with some testing or similar.
from magic-regexp.
Sounds awesome! 😀
Of course, if the other functions can also benefit of the inference, it's even better. I haven't worked yet with
.replace
with this library, but this sounds really game changing. It makes it so much easier to work with string manipulation of all kind.The inference looks great so far. Tell me if I can help with some testing or similar.
Definitely would love to have some helps on testing and improving it! ❤️
Will let you know as soon as I finish wrapping it up. 👍
from magic-regexp.
HI @didavid61202
Thank you. I've got a lot on my plate right now, so it might take me a moment. But I'll try to have a look at it this weekend.
from magic-regexp.
Sorry for my late response @didavid61202
I have tested the repo lately, and I couldn't find any breaking issue. I'm in awe of what this thing can do! 😍
Only one negative thing that I noticed: It seems to push either VS Code or the typescript language server to their limits. But this could be because of my pc, VS Code, TS, TLS, the repo itself with many complex examples, or any combination of those things...
I have a few minor things that I would like to discuss. E.g. what the restInput
key represents. Should I file an issue in your repo?
from magic-regexp.
Hi @michaelschufi, thanks!
Yes, I think this is pushing the language server to its limit by both lots of recursions and also lots of test examples. 😂 There are some performance issues that can be improved by a better parser and match algorithm. I've been testing some benchmark methods and I will start by rewriting the ParseRegExp
generic. Any inputs regarding performance improvement are welcome!
Do file issues if you have any questions 👍
The restInput
generic argument in RegExpMatchResult
represents the rest of input string that is not matched by the regexp provided, it's used for resolving the preceding string before the matching string, and getting the preceding string length for index
value of the match result.
from magic-regexp.
Hi @didavid61202
About performance:
I've just read about the TypeScript 5.1 Beta's release notes and came across the Negative Case Checks for Union Literals section. Maybe those optimizations also affect the regex type literals.
from magic-regexp.
Hi @michaelschufi,
Yes, I've been working on features similar to this, although might be in very different approach, it's a new type inferencing (fully parse, interpret, exact match, permutation all possible values) for string.match
, string.replace
, string.matchAll
and string.replaceAll
,
a little peek at what's possible (blue text are type hints from vscode-twoslash-queries
), still testing out with pure string literal:
Still have to finish writing more robust test cases and testing for some edge cases.
from magic-regexp.
Hi @michaelschufi, Here's the repository for the type-level RegExp parser and matcher. Check out examples in the 'tests/index.test-d.ts' file and others when you have some time. Please let me know if you encounter any issues or have any ideas. Thank you! 😄
👉 https://github.com/didavid61202/type-level-regexp
from magic-regexp.
Hi @michaelschufi, thanks for the info! 👍
I'll have to check if this affect the current implementation, or how we can utilize this to improve the performance
from magic-regexp.
Related Issues (20)
- `createRegExp` not sanitising strings (in type) HOT 1
- Very low contrast
- Incorrect open graph image HOT 1
- 500 - If you want to use `GithubLink` component, you must specify: `owner`, `repo` and `branch`.
- how do i recreate a password requirements regex? HOT 5
- No "exports" main defined in ....\.pnpm\[email protected]\node_modules\estree-walker\package.json HOT 3
- Lazy quantifier HOT 1
- not.word is not defined HOT 1
- Why is `MagicRegExpMatchArray` typed with `string | undefined`? HOT 3
- Allow for custom regex, and clarifying the usage of `anyOf()` HOT 7
- Library blocks Typescript compilation HOT 2
- Action Required: Fix Renovate Configuration
- Documentation site is down HOT 1
- Can I rework docs using Nuxt UI Pro HOT 4
- Maige Usage
- Support match everything in preset inputs
- [QUESTION] How to create typed function with RegExp or MagicRegExp input? (TypeScript)
- Unable to convert regex with custom character set to magic-regexp
- The esbuild plugin doesn't work flawlessly with tsup
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from magic-regexp.