Forum Archive

Regex Select Phrase Not Between Brackets

realburch

I have a block of text that looks like the below:

I need you to take a look at Bug 123 and Bug 2345. Also see the list below:
1. Bug 333
2. Bug 444
3. Bug 555

My workflow successfully insert markdown links for the referenced bugs through the use of the repeat block set to use each match of a regular expression. The resulting text looks like:

I need you to take a look at [Bug 123](www.bug.com?id=123) and [Bug 2345](www.bug.com?id=2345). Also see the list below:
1. [Bug 333](www.bug.com?=333)
2. [Bug 444](www.bug.com?=444)
3. [Bug 555](www.bug.com?=555)

My question is, if I want to run the workflow again, how can I prevent it from trying to rewrap matches that already have links.

The regex pattern I am using (?<!\[)\bBug\s\d+\b(?!\]), and although online python regex testers say the syntax is correct in only identifying Bug #'s not in brackets, it is not working in my workflow.

Thanks in advance

omz

Could you post the workflow you're using? Btw, normal workflow actions (i.e. not scripts) use Cocoa regular expressions, not Python's.

realburch

Gotcha. The workflow is posted here.

realburch

Nevermind I see what I did wrong.

I was naming my link tooltips the same name as the original text, which the workflow was then picking up on subsequent run throughs. the regex was fine.

I ended up just renaming the tooltips to something generic, but I could have also ignored Bug phrases wrapped in quotes.