I really can't get a regular expression to work for the following situation. I'm basically parsing some code files. I want to match each occurence of a word that is not preceded and followed by an alphanumeric character but only if there is no special character preceding this occurence. To make this more clearly an example:
Word to match:
Example text with in square brackets the number of matches I want:
This is some example text 
(v, c) = test_word 
% a = test_word(b); 
a = test_word(d); b = test_word(c); 
a = test_word; % b = test_word; 
d = this_test_word(c) 
With the simple expression:
\Wtest_word\W I get to match each occurence of
test_word regardless what comes beforehand. So I tried the expression
This works for all but the one case with two occurences. I just cannot get this one to work. I tried with lookaround assertions but I'm really stuck here.
Thank you a lot for your help!
If it matters I'm working in Matlab.