dazinator / DotNet.Glob

A fast globbing library for .NET / .NETStandard applications. Outperforms Regex.
MIT License
363 stars 27 forks source link

Defect: Patterns with Unsupported non alph-numeric characters fail to match #32

Closed MarkMichaelis closed 7 years ago

MarkMichaelis commented 7 years ago

It appers that a patterns with escape sequences fail:

dazinator commented 7 years ago

Currently the non-alphanumeric characters that are supported are restricted to this subset: https://github.com/dazinator/DotNet.Glob/blob/develop/src/DotNet.Glob/GlobStringReader.cs#L27

These characters are ones that are legal for file / directory paths.

Are you looking to match text within a text file or something?

MarkMichaelis commented 7 years ago

I was looking to find the equivalent of the Visual Basic or PowerShell like operators so yes. :)

dazinator commented 7 years ago

As per #31 - the issue is that when the pattern is tokenised, if the pattern contains a character that isn't in the allowed / supported subset of characters, then the token is silently omitted from the tokenised pattern. Then when you go on to do a match, you are actually matching now against a pattern that has those unsupported tokens omitted.

I am thinking I can address this in a couple of ways.

  1. Throw an exception if encountering an unsupported token in the pattern (this is obvious)
  2. Provide an option whereby you can "relax" character constraints on patterns.

The current constraints on the characters you can use are optimised for path / directory matching. Having an option to relax these constraints will allow you to use DotNet.Glob in a fashion more similar to VB's Like.

dazinator commented 7 years ago

I have just pushed 1.6.4 which fixes this problem! Read: https://github.com/dazinator/DotNet.Glob#parsing-options