PHP preg_replace replace text unless inside brackets
问题 I would like to use PHP's preg_replace() to search a text for occurrences of a certain word, and enclose that word in brackets, unless there are already brackets present. The challenge here is that I want to test for brackets that may or may not be directly adjacent to the text I am looking for. Random example: I want to replace warfarin with [[warfarin]] in this string: Use warfarin for the prevention of strokes but not in this string: Use [[warfarin]] for the prevention of strokes (brackets