Dart Regex (dart_regex) Package

Inspired by Tim Sneath’s bluesky post about Swift’s Regex DSL, I ended up building something similar in Dart

Here it is: dart_regex | Dart package

Any time I use regex in my flutter app, I end up writing at least a couple tests because of how easy it is to mess up regex syntax. As such my intention here is to bring type safety into the picture, and make it easier to write safe regex code that’s more readable as well.

It’s just a start so there’s plenty of functionality missing, but I think the basic most common building blocks are there. Would love to hear feedback, especially if any of you would be interested in using the package, and also about what regex features would be the most useful to add next

7 Likes

Great idea and generous from you to share - thank you!

1 Like

This should end in the dart lib.

I found it a nice introduction and in rich cases much more followable in reasoning than the compressed expression.

Bravo!

2 Likes

I wonder how hard it’d be to convert a petitparser | Dart package to a regex,

Nice idea, but have you checked verbal_expressions?

It’s a Dart version of a library popular in many other languages. I think it does most of what you’re trying to achieve.

1 Like

I did not know about it and yes that’s quite cool, I guess my package has just turned into something I’m gonna continue building just for the sake of getting better at regex then :slight_smile:

Thank you for sharing it

1 Like

@Hari_07. Perhaps aligning the naming conventions more closely with the Swift Regex DSL would provide added benefit not available in existing packages.
(I do think this could be done without changing your existing methods, but by adding additional Swift parallel alternatives)
Just an idea.

1 Like

It is a good thing that we have multiple similar packages taking different approaches. I believe there are people who prefer the syntax in your package. Looking forward to seeing you keep up the good work and seeing how good it will be as a result.