PHP Regexp negative lookahead
php, regex-negation
Solution
This happens because \w* "eats" the stopping word "_loop" before your check, to prevent that you should check the word first (before \w*), like the following:
$pattern = '/\{((?!\w*_loop\})\w*)\}/';
or you can use: `?< !` :
$pattern = '/\{(\w*(?<!_loop))\}/';
Problem
I'm trying match all words wrapped with { } but not the words with "_loop". I can't see where I'm going wrong with my reg expression. ``` $content = '<h1>{prim_practice_name}</h1><p>{prim_content}</p><p>Our Locations Are {location_loop}{name} - {state}<br/>{/location_loop}</p>'; $pattern = '/\{(\w*(?!\_loop))\}/'; ```