Regex multiple include/exclude string from single regex

jerome sergan 0 Reputation points
2023-03-24T08:22:51.8233333+00:00

Hi all, i need help , I would like to know if what I am trying to do is possible, I am using php to run an API to retrieve company data for a CRM, this API accept regular expressions to do the search, for exemple if i'm literally using “CEO”, i will match all that has the letters C, E, O within it and it is not case sensitive, i can make it precise by using the ^CEO$ regex to match just for the exact term of “CEO”, i can combine several search terms within one singular regex.

The goal, is to run a search in a SINGLE API call for several different strings like "CEO" and "OWNER" but ignoring if the target string contain a list of another strings like "assitant" and "junior" or "president".

For example :

https://xxxxx.com/api?search=|CEO|OWNER|president

target terms :

"OWNER", "assisant CEO", "OWNER and vice president", "CEO junior", "founder and director", "founder"

search string list :

"CEO", "OWNER", "founder"

ignore list :

"assisant", "junio", "president"

result must matche only :

"OWNER", "founder and director", "founder"

I specify that I shortened the terms to make it simple, in reality the target strings are paragraphs of text.
and there are maybe 10 strings to include and exclude.

Thank you all.

PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,445 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. Rich Matheisen 46,551 Reputation points
    2023-03-27T15:10:49.1166667+00:00

    Does it matter whether the "anti-string" precedes or follows the "desired-string"?

    In other word, should "president and CEO" fail but "CEO and president" succeed, or should both fail? Does it matter if the words are separated by other words, or by some word "distance" from each other, or must they just simply be present?

    It might be easier to use the API to get the string and then submit the string to a series of regexes in PowerShell.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.