Let's say i have the following string :
KEYWORD_1 OR "KEYWORD COMPOSITE_2" NOT "KEYWORD COMPOSITE_3" NOT "KEYWORD_4" AND "KEYWORD_5" KEYWORD_6 KEYWORD_7 KEYWORD_8 -KEYWORD_9
The result (this is not JSON format, just a visual formatting to explain the output) i want to get with my regex(es) is to split the string to the following three arrays of keywords, each one is corresponding to a delimiter (AND, OR, NOT) and contains all the words that follows every occurrence of the delimiter. Think of it like the google search field syntaxt :) :
final_result = {
{
OR: [KEYWORD_COMPOSITE_2]
},
{
AND: [
KEYWORD_1,
KEYWORD_5,
KEYWORD_6,
KEYWORD_7,
KEYWORD_8
]
},
{
NOT: [
KEYWORD_COMPOSITE_3,
KEYWORD_4,
KEYWORD_9
]
}
}
I am trying to do this in javascript with one or more regex.
Any idea ? any help ? thank you
AND: [ KEYWORD_1,JSON is correct? its String equivalent to a FORK? Diretio I still do not understand how it should work (I know what you need, the problem is your String has no logic in JSON format, the problem is to understand the logic)