Library/approach for glob based string matching?

I have searched but been unable to find a library to help with this. I would be interested to know if something exists and if not what the generally accepted approach might be? Does converting to regex generally get the job done or are the potential issues with that approach?

Javascript has glob which is based on minimatch which suggests that it converts patterns to regular expressions.

Generating a regular expression seems like a reasonable approach to me! I might use elm-tools/parser to parse the glob string to a simple AST data structure first and then compile that to a regular expression.

4 Likes

I might try taking it a step further: use elm-tools/parser to write a Parser which parses a glob string into another Parser!

(“Yo dawg, I heard you like parsers…”)

6 Likes

Thanks for the advice. I’ve started work on this here: https://github.com/michaeljones/elm-glob

I would welcome any advice on improving it as it develops. I’m pretty sure I’m going to miss some critical stuff around the translation but it is fun to try!

4 Likes

This has been published here: http://package.elm-lang.org/packages/Zaptic/elm-glob/latest

I would very much welcome any feedback or help in making sure it is well behaved.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.