Results 1 to 6 of 6

Thread: String Wildcard Search

  1. #1

    Default String Wildcard Search

    Hi All

    I am looking for files which have "Invoice Breakdown*17.xls*" as part of the file name, what script (other than strFind) function can I use in order to perform a wildcard search in a string?

    Understood that strFind is available, but there are simply too many variations to the file names, see example below:

    Invoice Breakdown Jan17.xls
    Invoice Breakdown Jan17.xlsx
    Invoice Breakdown Jan2017.xls
    Invoice Breakdown_Jan_17.xls
    Invoice Breakdown_Jan_2017.xls
    Invoice Breakdown Jan 2017.xlsx
    Invoice Breakdown January 2017.xlsx

    Thanks.

  2. #2
    Contributor
    Join Date
    Apr 2011
    Location
    Copenhagen
    Posts
    129

    Default

    I don't see why you couldn't use the StrFind function?

    emit * where YourField.toLower().strFind("invoice breakdown") > -1
    and YourField.toLower().strFind("jan") > -1
    and YourField.strFind("2017") > -1

    After that I would check the data to see if I was missing anything.

  3. #3
    Lavastorm Employee
    Join Date
    Nov 2012
    Location
    Warrington, UK
    Posts
    200

    Default

    You can use the regular expression matching operators - regexIsMatch and the case-insensitive version regexIsMatchI in a Filter node.

    For example, if the file name is in the 'FileName' field, this script will output the matching records (case insensitive):

    Code:
    _Match = FileName.regexIsMatchI("Invoice Breakdown.*17.xlsx.*")
    
    emit * where _Match
    If the files are in an accessible directory, you could also use the pattern matching capability of the Directory List node to obtain the matching filenames. Case sensitive matching is only supported on Unix-style platforms, not Windows.

  4. #4

    Default

    hi awilliams1024

    This awesome!!! using both "*" and "." ...... brilliant!!! I only tried them individually becaseu the help file did not give any example on using the jointly.

    ThomasT, thanks for your suggestion as well..... you can't really go about coding out every single possible senario, say you got 20 crieria like the example above and each one has 20 variations, that'll be 400 combinations.
    Are you seriously going to code all of them out?

  5. #5
    Lavastorm Employee
    Join Date
    Nov 2012
    Location
    Warrington, UK
    Posts
    200

    Default

    Hi jpstory, you are welcome.

    One minor update to the regular expression pattern - the current pattern matches filenames that will have any single character between the '17' and 'xlsx'.
    If you want to restrict this to matching only the period '.' character the pattern should be:

    _Match = FileName.regexIsMatchI("Invoice Breakdown.*17\\.xlsx.*")

    Regards,
    Adrian

  6. #6

    Default

    Hi awilliams

    You totally nailed it .... I was going to ask that question. Thanks so much!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •