0

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

Glenn Sampson
  • 1,188
  • 3
  • 12
  • 30
  • Remove that `$`. It means "end of string", and it won't match anything after it. – paulotorrens Jul 12 '16 at 01:39
  • 1
    `VCS([a-zA-Z]*)_[0-9]{8}_OMEGA[.]csv` ..in regex universe `.` matches anything(_so escape it or add it to character class_) and `$` marks end of string – rock321987 Jul 12 '16 at 01:39

1 Answers1

2

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.

Sebastian Lenartowicz
  • 4,695
  • 4
  • 28
  • 39
  • 1
    `^` and `$` match the beginning and end of a line, not the beginning and end of the entire string. This means that `"ZOMG\nVCSTrades_00000000_OMEGA.csv\nKTHX"` will match your regex. `\A` and `\Z` are better suited. – Olathe Jul 12 '16 at 01:53