Ftp server has following files created on daily basis.
- FGI_WTYUIO_D_2016_04_16_BS.daily.gzip - BS File
- FGI_WTYUIO_D_2016_04_16_BV.daily.gzip - BV File
- FGI_GHJK_D_2016_04_16_SATB3.daily.gzip - B3 File
- FKI_GHJK_D_2016_04_16_SAT.daily.gzip - BV File
- FKI_GHJK_D_2016_04_16_SATB3.daily.gzip - B3 File
- FKI_GHJK_D_2016_04_16_SATBS.daily.gzip - BS File
- FKI_GHJK_D_2016_04_16_SSD.daily.gzip - Need to Ignore
- FKI_GHJK_D_2016_04_16_SSDBS.daily.gzip - Need to Ignore
So, basically there two filetypes
- FGI
- FKI
and Three Report code for each Filetypes
- BS
- BV
- B3
I need to ignore rest of the files. (SSD files).
I need to write regex pattern inside Javascript to fetch these files. which has following variables.
- fileDate - Date ex. 2016_04_16
- matchReportCode - ex. BV,BS,B3
So, if fileDate = 2016_04_15 and matchReportCode='SV' (BS,BV). Then I should only fetch following files.
- FGI_WTYUIO_D_2016_04_15_BS.daily.gzip - FGI BS File
- FGI_WTYUIO_D_2016_04_15_BV.daily.gzip - FGI BV File
- FKI_GHJK_D_2016_04_16_SAT.daily.gzip - FKI BV File
- FKI_GHJK_D_2016_04_16_SATBS.daily.gzip - FKI BS File
So, if fileDate = 2016_04_19 and matchReportCode='3S' (B3,BS). Then I should only fetch following files.
- FGI_WTYUIO_D_2016_04_15_BS.daily.gzip - FGI BS File
- FGI_GHJK_D_2016_04_16_SATB3.daily.gzip - FGI B3 File
- FKI_GHJK_D_2016_04_16_SATB3.daily.gzip - FKI B3 File
- FKI_GHJK_D_2016_04_16_SATBS.daily.gzip - FKI BS File
So far I could only come up with this.
FileRegex = "F[KG]I_.*_D_" + fileDate + "_[A-z]{0,3}L{0,1}[" + matchReportCode + "]{0,1}.daily.gzip";
Can someone please help ? I am new to regex. Thanks.