I am in a situation that I need to extract words/variables from a string(expression). I tried to accomplish this. The following situation is valid:
OK/Test(ANSWER[12])+SUM(Test(ANSWER[..]))*OK+ANSWER[14]
I need to extract the "OK" "variables". I managed to extract other components like ANSWER[..] e.g. These variables are dynamic ofcourse.
I already tried things like:
/[a-zA-Z]*(?!\(|\[)/g
But this also returns SU (From SUM, which is not desired)
Thanks in advance :)
Edit: clarification
I need to extract words that are only surrounded by whitespace (begin or end of string) or +-*/ operators. Words that have ()[] before or after them should be ignored.
@"(?<![^\s+*/-])\w+(?![^\s+*/-])"or@"(?<![^\s+*/-])[A-Za-z]+(?![^\s+*/-])"(depending on what the "word" is for you here).