This is one of many situations where lookbehind seems like the obvious tool for the job, but you can't use it. The main problem is that a lookbehind subexpression can't use quantifiers like ?, *, +, or {min,max}, so this won't work:
preg_match('~(?<!//.*)\bthis\b~', $subject, $match); // nope!
In most regex flavors you would have to match the whole line with a regex that doesn't allow // to appear anywhere before the token you're looking for. @Gumbo showed one way to do that, and here's another:
preg_match('~^(?:(?!//).)*\bthis\b~', $subject, $match);
If your goal is to replace the token with another--for example, replacing this with that--you'll have to capture the stuff before it and plug it back in:
preg_replace('~^((?:(?!//).)*)\bthis\b~', '$1that', $subject);
However, PHP offers another option: \K, Match Point Reset operator (or as I like to call it, "Poor Man's Lookbehind").
preg_match('~^(?:(?!//).)*\K\bthis\b~', $subject, $match);
You match the preceding matter in the usual way, but the \K tells the regex engine to pretend the match really started just before the \bthis\b, not at the beginning of the string, so the value of $match[0] is simply "this". If you're doing a replace, there's no need to capture the preceding matter and plug it back in:
preg_replace('~^(?:(?!//).)*\K\bthis\b~', 'that', $subject);
\K originated in the Perl regex flavor.