I have a series of files which contains either a Windows file path, a Linux one or both.
Regardless of the OS, it's always formatted between quotes and ending in a semi-colon. For example:
"Z:/WorkDrive/_users/userName/_project/asset/asset_type/asset_name/asset_file.ext";
"/work/asset/type/name/versions/asset_file.ext";
The windows drive could start with any letter followed by an unknown folder name. And (surprisingly), the windows file paths don't contain \'s (which is odd for me!)
I want to write two regex expressions. One to pick up the Windows files and the other to pick up only the Linux ones but without the quotes.
So far, I've got:
(?!=\")[a-zA-Z]:\/(?:[a-zA-Z0-9() ]*\/)*.*(?=\"\;) #For Windows paths
(?:=[a-zA-Z]:\/|\")/.*(?=\"\;) #For Linux paths
The windows one works as desired - it doesn't capture the Linux path. But I'm struggling with the Linux one. So far, the above is the closest I've got, but it's including a " mark at the beginning, which isn't what I want. If I remove the |\" from the first segment of the Linux regex, it fails.
Can anyone think of a better way to capture only the Linux file path and skipping any windows file path (ie, if a line starts with "Z:/" move on)?
Thanks
Comments
Post a Comment