Regex with a wildcard text string

1.8k Views Asked by At

I have 2 file patterns

  • VCSTrades_yyyymmdd_OMEGA.csv
  • VCSPositions_yyyymmdd_OMEGA.csv

I was hoping to use the 1 regex but i'm having difficulty with anything after the first underscore

This is what i thought would work

VCS([a-zA-Z]*$)_[0-9]{8}_OMEGA.csv

Please help

1

There are 1 best solutions below

1
On BEST ANSWER

A complete regex that matches what you're looking for and nothing but:

\AVCS(Trades|Positions)_[0-9]{8}_OMEGA\.csv\Z

If this pattern will occur within a line of text, remove the \A and \Z from the beginning and end, respectively.

Also, if you want to test out regexes, I recommend a website like Rubular - it tests your regex in real-time against any text you put in the box.