Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

CEnum - File Enumeration and File Globbing Class

, 6 Dec 2008
CEnum is used for enumeration of files and directories using wildcard matching (globbing)
# test zero or more characters

"*"                 ""                                      true
"*"                 " "                                     true
"*"                 "a"                                     true
"*"                 "a "                                    true
"*"                 ".a"                                    true
"*"                 "*"                                     true
"*"                 "?"                                     true
"*"                 "abcd"                              true
"*"                 ";+*'?(/&%$#!_"             true

# test exactly one character

"?"                 ""                                      false
"?"                 " "                                     true
"?"                 "a"                                     true
"?"                 "."                                     true
"?"                 "?"                                     true
"?"                 "*"                                     true
"?"                 "!"                                     true
"?"                 "ab"                                    false

# at least one character, any character

"*?"                ""                                      false
"*?"                " "                                     true
"*?"                "a"                                     true
"*?"                "ab"                                    true
"*?"                "a.b"                                   true

# at least one character, last one is 'b'

"*b"                "b"                                     true
"*b"                "ab"                                    true
"*b"                "aab"                                   true
"*b"                "abc"                                   false

# exactly two characters, second one is 'c'

"?c"                "c"                                     false
"?c"                "bc"                                    true
"?c"                "abc"                                   false
"?c"                "bcd"                                   false

# at least two characters, last one is 'c'

"*?c"               "c"                                     false
"*?c"               "bc"                                    true
"*?c"               "abc"                                   true
"*?c"               "abcd"                                  false

# same test, just with inverted wildcard chars

"?*c"               "c"                                     false
"?*c"               "bc"                                    true
"?*c"               "abc"                                   true
"?*c"               "abcd"                                  false

# file name test, find strings with a dot in it

"*.*"               ""                                      false
"*.*"               " "                                     false
"*.*"               "."                                     true
"*.*"               ".ab"                                   true
"*.*"               "a.b"                                   true
"*.*"               "ab."                                   true
"*.*"               ".a.b"                                  true
"*.*"               "a..b"                                  true
"*.*"               "..."                                   true

# test reoccurring substrings

"ab*cd*ef*gh"       "ab c1 cd e1 ef g1 gh"                  true
"ab*cd*ef*gh"       ""ab*cd*ef*gh"                          true
"ab*cd*ef*gh"       "abcdefgh"                              true

# misc, some of these might already been tested previously

"*t?st?n*this*t*"    "testin this sh*t"                     true

"????"              "abcd"                                  true
"????"              "abcde"                                 false
"*b"                "abc"                                   false
"a*???bc"            "axxxxbcxxxxbc"                         true
"a*???bc"            "axxxxbdxxxxbc"                         true
"a*???bc"            "axxxxbcaxxxxbc"                         true
"a*bc"               "axxxbcxxxbc"                           true

"*?"                "ab"                                    true
"*?c"                "abc"                                    true

"*b"                "abc"                                   false

"*???"				"ab"									false

"*?"                "ab"                                    true
"*?"                "a"                                    true
"*?"                ""                                    false
"*?a"                "aa"                                    true
"*?a"                "ba"                                    true
"*?a"                "a"                                    false
"*?"                ""                                    false

"a*bc"             "aabdbc"                                 true
"a*bcdef"          "aabcderdbcbcdef"                        true

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Loreia

Croatia Croatia
Nothing to brag about.
Just another engineer who works as a software developer last couple of years.

| Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 6 Dec 2008
Article Copyright 2008 by Loreia
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid