Wildcard - Variable Expression

Hi,

I have used excel reader > table row to variable > variable expression to configure a path. As the file could be in “.xls” or “.xlsx” format. I would like to know how to put wildcard .xls in the variable expression node so that both file format could be picked up


Variable Expression Testing.knwf (10.7 KB)

Hi mmngeoh,

I’m not sure exactly what expression you would need, because I’m not sure what you would like to do with the evaluation (i.e. would you like a true/false variable depending on if there is .xls(x) or something else), but in order to check if “.xls” is contained, you can use:
contains(variable("main_file_path"),".xls")

If you want to check that the .xls(x) is contained strictly at the end of the string, I would use Regex:
regexMatcher(variable("main_file_path"),".*\.xlsx?")

Hope this helps, let me know if not! Cheers,
Karen

1 Like

Hi @kabrah,

Sometimes the file format i want to extract following the path is in “.xls” format but sometimes it is in “.xlsx”, so i would like to have at least “.xls” in the path (maybe using a wildcard) to ensure that file in both “.xls” and “.xlsx” could be read.

Regards,
Ming Ming

1 Like

hi @kabrah,

I have found the solution for this, to use file filter options in excel reader node and insert wildcards there. For example, i have file YYMM_draft_for_YYMM in “.xls” and “.xlsx”, this wildcard could help to detect the file in both formats

Btw, Thanks for your help :blush::blush:

2 Likes

Hi Ming Ming! Really cool, I didn’t think to check the Reader node’s options, but glad you figured it out!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.