Comments (11)
@cocowalla - this is now fixed if you upgrade to: https://www.nuget.org/packages/DotNet.Glob/1.6.0
from dotnet.glob.
Ok so this is what you should be seeing by design:
Shock* 12
should not match HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Shockwave 12
.
*Shock* 12
should not match HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Shockwave 12
.
**\Shock* 12
should match HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Shockwave 12
.
*ave*2
should not match HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Shockwave 12
.
**\ave*2
should match HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Shockwave 12
.
I have added unit tests to verify that the above is correct. The successful matches are: here and failed matches are here
Basically. the pattern is matched against the whole string, starting with the first token. A *
will match any number of (including none) any characters within a single segment
only.
So *
will not match hi\there
because *
only matches a single segment, so in that example, it would only match the portion: hi\
. Where as **
behaves the same as *
except it will also match any number of segments. So **
will match hi\there
.
*
can be used anywhere in a pattern. For example *foo*baz
will match foobarbaz
. **
however, if used in a pattern, it must be the only thing within a segment. You can't have a pattern like this: **foo
or baz**\foo
. But you could have foo\**\baz
is fine and would match foo\bar\baz
and would also match foo\bar\bat\baz
.
Chances are, if you are not seeing this behaviour, you may be using an older version of dotnet.glob
as some stuff around this was fixed in later releases.
What version of dotnet.glob
are you currently using?
from dotnet.glob.
Am closing this for now, but feel free to comment further if you need more clarification. Might also be worth checking you are using atleast version 1.5.0
from dotnet.glob.
I'm using the 1.6 preview from 06- May. Will try upgrading to the latest preview layer and see if it still behaves the same.
from dotnet.glob.
Firstly, thanks for taking the time to write such a detailed description.
*
will match any number of (including none) any characters within a singlesegment
only.
Given this, shouldn't Shock* 12
match Shockwave 12
from the last segment of HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Shockwave 12
? (Especially since *ave 12
does - or is this meant to not match?)
As another example, *12
does match, S*12
does not.
from dotnet.glob.
*ave 12 is not meant to match. I think one of the unit tests I pointed to should cover that case.
from dotnet.glob.
Given this, shouldn't
Shock* 12
matchShockwave 12
from the last segment ofHKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Shockwave 12
?
Shock* 12
should match the string Shockwave 12
. But it shouldnt match the string HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Shockwave 12
. The pattern Shock* 12
means the string should start with the literal Shock
then have 0 or many characters, then have the literal 12
. The string being matched starts with H
so fails the match straight away. If you want to match the end of a string, and you dont care about the beginning, the pattern should start with **\
as that will match any number (including 0) of any characters, any mumber of segments deep. So **\Shock* 12
should match.
from dotnet.glob.
OK, I understand now; *
is only really useful for matching filenames (or the last path segment for registry keys) if you're matching a path that doesn't contain directory separator characters, since IsMatch
matches on the entire subject string. I think what I want to do then is: when glob patterns don't contain any directory separator characters, match on Path.GetFileName(subject)
, otherwise match on the full path. But I get that isn't standard glob functionality, so I'll implement it in my application's code.
BTW, *ave 12
definately matches in the preview version on NuGet.
from dotnet.glob.
BTW,
*ave 12
definately matches in the preview version on NuGet
Hmm ok thanks for letting me know. I'll try and replicate it. So just to be clear, you are saying with the latest prerelease nuget package, the pattern *ave 12
matches that shockwavw key local machine reg key? If thats correct ill see if I can reproduce this.
from dotnet.glob.
Yes (I just double-checked to be sure)
from dotnet.glob.
Ok - have replicated this bug. Will fix in next release.
from dotnet.glob.
Related Issues (20)
- IndexOutOfRangeException with ** HOT 9
- Bring dotnet glob to sql clr and ef core! HOT 2
- New option for parsing behaviour of invalid ** HOT 9
- Enable sourcelink HOT 1
- Fix build - GitVersion issue. HOT 2
- Build failing
- How to enumerate files and folders with glob? HOT 1
- Cannot build, deprecated dotnet dependencies and more HOT 2
- "**/.*" unexpectedly matches paths ending with dot HOT 4
- Glob failing on matching `/` with Index was outside the bounds of the array HOT 2
- Consider joining the .NET Foundation
- Double check character class logic HOT 1
- Composite character ranges
- Matching partial paths? HOT 2
- Having a dot after a wildcard in a pattern that also has literal directory and wildcard directory matchers can fail to match a valid path HOT 2
- Lots of bugs HOT 7
- Linux filenames with slashes HOT 3
- Multiple Glob Patterns HOT 2
- Inconsistent Matching HOT 2
- README fluent builder example is wrong
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 dotnet.glob.