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

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

Closed
MarkMichaelis opened this issue Jul 12, 2017 · 4 comments

Comments

@MarkMichaelis
Copy link

MarkMichaelis commented Jul 12, 2017

It appers that a patterns with escape sequences fail:

  • DotNet.Globbing.Glob.Parse("\"Stuff*").IsMatch("\"Stuff"): false
  • DotNet.Globbing.Glob.Parse("\0Stuff*").IsMatch("\0Stuff"): false
  • DotNet.Globbing.Glob.Parse("\nStuff*").IsMatch("\nStuff"): false
  • DotNet.Globbing.Glob.Parse("\r\nStuff*").IsMatch("\r\nStuff"): false
@MarkMichaelis MarkMichaelis changed the title Defect: Patterns with Quotes Fail Defect: Patterns with Escape Sequences Fail Jul 12, 2017
@dazinator
Copy link
Owner

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
Copy link
Author

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

@dazinator dazinator changed the title Defect: Patterns with Escape Sequences Fail Defect: Patterns with Unsupported non alph-numeric characters fail to match Jul 12, 2017
@dazinator
Copy link
Owner

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
Copy link
Owner

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

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

No branches or pull requests

2 participants