I'm working in JavaScript/TypeScript.
I have a string that may include a some tags that indicate importance or urgency. Example:
A: "Remind me to go to the store tomorrow. It is really important"
B: "It is important to go to the store tomorrow."
I have built a method to identify where the importance phrase exists in the main phrase. For instance, for string A, the importance phrase comes between characters 40 and 62. In phrase B, it comes between character 0 and 16.
I have a JSON object that describes the start/stop points of the importance phrase:
this.importancePosition = { start: 40, stop: 62 }
No problem.
So I have other phrase element detectors:
this.urgencyPosition = { start: 20, stop: 30 }
this.locationPosition = { start: -1, stop: -1 }
and so on.
By the way, I'm using -1 as an indicator that the token has not been found. Also, the sub-phrases may not come in order.
So here's the question:
Let's say I have the main phrase and the locations of each of the detected sub-phrases. Now, I want to return everything from the main phrase that is not part of one of the sub-phrases.
I have this:
[aaaaaaaaaaaaaaaaa[subphrase]bbbb[subphrase]ccccccccccccccccccccccccccccccccccccccccc[subphrase]]
I want to return this:
[aaaaaaaaaaaaaaaaa bbbb ccccccccccccccccccccccccccccccccccccccccc]
What is an efficient way to do this? I've considered regex-ing them out of the main string, but is that the cleanest way?