I'm using RegEx to search multiline string, that contains a list of file paths.
The goal is: if the match is in folder name - return this folder path only (do not return any subfolder if they match too). And, if the match is in file name, then return the whole line (full file path).
Pattern I'm currently using returning the whole string: .*([^\\]*(John|Smith|Junior)){2}.*
Desired returned string:
C:\temp\John Smith Junior\file.pdf -> C:\temp\John Smith Junior\
C:\temp\John Smith Junior\John Smith Junior\file.pdf -> C:\temp\John Smith Junior\
C:\temp\John Smith Junior file.pdf -> C:\temp\John Smith Junior file.pdf
I tried adding to the end of the pattern stuff like: [\\n] or (\|\n) or (?!=.+\) but that's not working exactly as I want. Thanks for any help!
Demo: https://regex101.com/r/98d6Ed/1
.*([^\\]*(John|Smith|Junior)){2}.*