[Solved] iOS Shortcut, regex match these words, while excluding these words

aetheryl Asks: iOS Shortcut, regex match these words, while excluding these words
This is my first post on StackExchange. For years I have lurked on here and most of the time found my questions already answered by other users on here.

I am using iOS Shortcuts and am using it get contents of page (converts the page to RTF), then running through make text to turn it into plain text.

I am trying to develop an IUC flavored regex to search for key words/phrases on a list of pages I am looping over with a while each, but want the regular expression to exclude other phrases and prevent a false-positive trigger.

I have it set up with two capture groups. I’m not sure if it is desired to make the second group a non-capture group, or not attempt capture at all. I only think the second one must be either a capture, or non-capture group for the logical AND provided. I read that (this)(that) acts as an and, but I’m not sure if either is a negate, whether it follows that logic. For that reason, I’m not sure if the negate should not be it’s own capture group, non-capture group, or shouldn’t be using the brackets at all. I had tried some nested capture group stuff, but that seems to not follow the syntax.

Currently, I have tried a wide variety of regular expressions. I do not have a full list, but I can share a few permutations I have tried starting with the most recent:



Just to be clear, I want it to first search the exclude terms and fail if it finds one. Then if it doesn’t find any of these negate terms, then begin searching through the include terms. It is fine that the include list and exclude list terms, respective to each grouping are being treated on an OR basis (per piping |) as that is the intended behavior I’m seeking. Finally, I am wanting to start my search at the top of the page and for it to stop searching / attempting capture in this logical order:

  • Exclude term found, STOP — First include term found, STOP

Final note, this search is obviously performed over multiple lines. I am only seeking to capture the include term, not the exclude term. I only want the exclude term to cancel out a match of both exist (either before or after – cross directionally). That is if an exclude term exists, negate the positive term and provide zero matches.

Thanks in advance for your help and I apologize if I am not following proper etiquette on my first post and I am open to your feedback.

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.