In MS Project, tasks can be linked to multiple other tasks which can reside in separate (external) project files. The only way to get a reference to these externally linked tasks is to parse out the "Predecessors" field which is a comma-separated list of links. Unfortunately, those external links can have commas in the paths, so a simple split doesn’t work.
Here is an example with 3 links, the second is external:
123FS+5d,\\server\folder, with commas\project1.mpp\456,789
For internal links, the format can be any of the following:
- #tk
- #tk+#d
- #tk-#d
Where the first number is the ID, the placeholder tk can be FS, FF, SS, or SF, and the optional last part (the lag) is +/- # days.
For external links, the link information is preceded by the file name including the path, followed by a backslash. The path may be UNC (e.g. \\) or a mapped drive letter (e.g. L:\).
There can be one or more links in a field and all, some, or none can be external.
I need a regex pattern to match these lists of links.
Thank you for the assistance!
EDIT
For posterity’s sake, here’s the pattern that works best as it also matches paths from Project Server ("<>\file name\123")
(((<>\\[^\\]+\\)+)|([A-Z]:|\\)\\([^\\]+\\)+)?\d+([FS]{2}([+-]\d+d)?)?(?=,|$)
Also see How can I get the Unique ID of an External Dependency Task? for further enhancement on this regex pattern.
Initial Answer:
Using a modified version of the sample you provided and putting in a bunch of other things, I came up with this expression:
It identifies a comma that is followed by one of your possible patterns, and you SHOULD be able to use it to split your stuff out (I think) – let me know if you have problems and I’ll try to help – running off to a meeting right now 😀
EDIT:
To match the links themselves, rather than splitting, remove the initial comma and lookahead from the expression, like so (this is often the case for converting split expressions to match expressions, but not always…):