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

exocad: conversion of wildcard to regexp is broken #1

Open
eaexo opened this issue Mar 15, 2016 · 2 comments
Open

exocad: conversion of wildcard to regexp is broken #1

eaexo opened this issue Mar 15, 2016 · 2 comments

Comments

@eaexo
Copy link

eaexo commented Mar 15, 2016

Generation of search pattern in FindFileSystemEntryInfo is incorrect:
"^" + Regex.Escape(_searchPattern).Replace(@"\.", ".").Replace(@"\*", ".*").Replace(@"\?", ".?") + "$"

correct one is
String.Format("^{0}$", Regex.Escape(part).Replace("\\*", ".*").Replace("\\?", "."))
see http://www.codeproject.com/Articles/11556/Converting-Wildcards-to-Regexes
Importandt is that:

  • . is not replaced by . as it produces for "test.txt" the regular expression ^test.txt$ which also matches testatxt.
  • ? is replaced with . as ? as wildcard matches exactly one characted, see https://en.wikipedia.org/wiki/Wildcard_character. Where as .? matches 0 or 1 characters. Hense wildcard a?a would become a.?a and would match aa and aba where the correct match would be only aba
@eaexo
Copy link
Author

eaexo commented Mar 15, 2016

in commit dd3cbf3 gefixt

@eaexo
Copy link
Author

eaexo commented Mar 15, 2016

Open topics:

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

1 participant