0

I am trying to build a RegEx to handle multiple variations in a file path vs. having to perform several definitions of a path to search for a file but also not hammering the system. The RegEx expression is within a 3rd party tool that's configuration supports RegEx syntax.

I have an extensive file structure that in multiple different points in the path (relay_X, and pathX in example below) there are variations.. otherwise it is consistent (including case) and containing many other directories that I do not care about. In each directory marked as 'varies' there can be up to 20 individual directories which quickly results in quite a multiplication factor.

Currently I have to define each path individually and I want to try to trim it down to find any error files and there are several hundred paths without hammering the system as it is looking every 10 seconds for new error files.

The consistent path of each directory is C:\test\varies\processing\error\varies\varies\*.err.

What I known works if I first fully set the search path .*\.err

C:\test\relay_d\processing\error\relay_d\patha\err.Bob.err C:\test\relay_d\processing\error\relay_d\pathb\err.Cap.err C:\test\relay_d\processing\error\relay_e\patha\err.Bob.err C:\test\relay_d\processing\error\relay_e\pathb\err.Cap.err C:\test\relay_e\processing\error\relay_d\patha\err.Bob.err C:\test\relay_e\processing\error\relay_d\pathb\err.Cap.err C:\test\relay_e\processing\error\relay_e\patha\err.Bob.err C:\test\relay_e\processing\error\relay_e\pathb\err.Cap.err

I have tried the Recursive RegEx answer here which is similar to this answer and this answer; though to date none have worked.

I used RegExr.com to come up with this .*\\processing\\error\\*\\*\\[^/]*.err which matches there.. but when I tried the solutions above none actually returned any results.

Question: What RegEx expression would allow me to compress my entries down to just having to definie just C:\test\relayd\ and C:\test\relaye\ to find the .err files located several steps deep?

Community
  • 1
  • 1
CRSouser
  • 658
  • 9
  • 25
  • 2
    There are several variations of Regular Expression syntax. Have you verified which dialect your tool is actually supporting? Once you got that figured out, the rest should be easy. – Cyb3rFly3r Apr 30 '16 at 00:59
  • @Cyb3rFly3r No I didn't realize there were different dialects. I will need to check with the vendor. – CRSouser Apr 30 '16 at 00:59
  • You may find that information in the tool documentation, if it is available to you. The dialects are similar but the minor variations are significant enough to matter when you want to nail down a specific behavior like in this case. – Cyb3rFly3r Apr 30 '16 at 01:02

1 Answers1

2

Try this:

C:\\test\\relay_[de]\\processing\\error\\[^\\]+\\[^\\]+\\[^\\]+\.err
Steven Doggart
  • 43,358
  • 8
  • 68
  • 105