Commons IO
  1. Commons IO
  2. IO-246

FilenameUtils.wildcardMatch gives incorrect results

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.4
    • Fix Version/s: 2.0
    • Component/s: Filters
    • Labels:
      None
    • Environment:

      any

      Description

      This wildcard pattern "*?" does not match correctly. The command:

      System.out.println(FilenameUtils.wildcardMatch("aaa", "*?"));

      prints out "false", even though it matches. The wildcard mask is a bit unusal, but not incorrect. It should match any input with at least one character.

        Activity

        Hide
        Niall Pemberton added a comment - - edited

        While you're probably right that using "*?" in a wildcard expression should work as you expect - it would be difficult to fix wildcardMatch() to cater for this.

        Using

        "?*"

        effectively means the same thing - unfortunately this does not work either - but its much easier to fix. Also in my mind its more precise. For example an expression like

        "aa?*"

        always means "any character in the third position" for the "?" wildcard.

        Show
        Niall Pemberton added a comment - - edited While you're probably right that using "*?" in a wildcard expression should work as you expect - it would be difficult to fix wildcardMatch() to cater for this. Using "?*" effectively means the same thing - unfortunately this does not work either - but its much easier to fix. Also in my mind its more precise. For example an expression like "aa?*" always means "any character in the third position" for the "?" wildcard.
        Show
        Niall Pemberton added a comment - Fixed, http://svn.apache.org/viewvc?view=revision&revision=1002582

          People

          • Assignee:
            Niall Pemberton
            Reporter:
            vva
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development