what is the regex syntax to recognize 1 or possibly 2 or possibly 3 numeric characters in a row separated by underscores?

Viewed 27

I am facing the same problem. pattern = '.RESPONDENT_[0-9]..csv.gz'; using above command I am getting 4 results but removing .* from the begning of pattern, I am getting 0 results. please help

RESPONDENT_0_0_0.csv.gz

RESPONDENT_1_0_0.csv.gz

PROJECT_SLICE_RESPONDENT_0_0_0.csv.gz

PROJECT_SLICE_RESPONDENT_1_0_0.csv.gz

2 Answers

This will work for the regexp

RESPONDENT(_\d){1,3}\.csv\.gz

Just remember to escape the backslashes in the Snowflake literal. It will (probably) need to be:

'RESPONDENT(_\\d){1,3}\\.csv\\.gz'

Try this out(supports +3 digits), i gave it a few tests here:

^.*_\d.*$
Related