Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Regex Select Phrase Not Between Brackets
-
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:
- Bug 333
- Bug 444
- 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:
- [Bug 333](www.bug.com?=333)
- [Bug 444](www.bug.com?=444)
- [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
-
Could you post the workflow you're using? Btw, normal workflow actions (i.e. not scripts) use Cocoa regular expressions, not Python's.
-
Gotcha. The workflow is posted here.
-
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.