Click here to Skip to main content
11,702,981 members (61,596 online)
Click here to Skip to main content
Add your own
alternative version

CEnum - File Enumeration and File Globbing Class

, 6 Dec 2008 CPOL 29K 882 46
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.

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150819.1 | Last Updated 6 Dec 2008
Article Copyright 2008 by Loreia
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid