I am trying to isolate ABBY COURT from a folder path and I am close, but I just can't get rid of the tail end. What am I missing?
Question
Question
Pattern Matching in Workflow
Replies
Your expression is a little bit generic (and actually too specific, too, sometimes), but it may be sufficient depending on your context (e.g., your repository folder organization and what you're trying to match).
Currently, it'll match any 2 word folder name that follows a one letter folder name. And it'll actually match a bunch of other things, too, since you're using \W (any non-word character) instead of something more specific like \\ (backslash literal). And it *won't* match a 3 (or more) word folder name after the single letter folder (e.g., "Abby Superior Court" would not be captured), nor will it match a name that contains apostrophes or periods or other common symbols.
You may want something more like this:
\\[A-Z]\\([^\\]+)\\
(this matches a single letter path followed by everything between the next two backslashes, by using a character class that says "match everything except a backslash")
Disclaimer: it's difficult to create a robust pattern with only one example--ideally you should test this pattern on dozens of different examples.
Actually, I think I got it. I removed the .* and went with:
\W\w\W(\w*\s\w*)\W
If there is a better or more efficient pattern, please let me know!