I need a regex expression for matching a word that immediately precedes a keyword, but doesn't match the keyword itself. For example, in the following text:
"this is some text keyword"
the regex expression should match "text" (assuming "keyword" is the keyword). I should also note that the keyword will always appear as the last word on a line. So far I've come up with this regex:
((?:\S+\s)?\S*keyword\n)
but that matches both the preceding word and the keyword itself (so in the above example it would match "text keyword" instead of just "text"). Does anyone have any advice for this? I'm still learning regex. Thank you!!