To answer your general question: "How to match anything until a character except the character?"
You can use the following regex:
"(.*)(?=word)"
This uses the "look ahead / look behind" construct (?=something) to match everything until the certain word and excluding that word.
Example
Test string ==> 'I don't understand the meaning of this word or anything else'
"(.*)(?=word)" applied
'I don't understand the meaning of this'