Python regex pattern: find single “o” letters (multiple o-s should be excluded)
['xxoxoxoxoxoxooxxxxox\n', 'xxxxxxxxxxxxxxxxooox\n', 'xoxoxoxoxoxoxoxoxoxo\n', 'ooxoxoxoxoxoxoxooxox\n', 'xxxxxxxxxxxxxxxxoooo\n', 'xxxxxxxxxxxxxxxxxxxx\n', 'oooooooooooooooooooo\n', 'xxxxxxxxxxooxxxxxxxx\n', 'xooxxxxxxxxxoxxxxxoo\n', 'xxxxxxoxxxxxxxoxxooo\n', 'xooooooooxoooooooxxx\n', 'ooooooxoxoxoxoxoxoxo\n', 'oxxxxxxxxxxxxxxxxxoo\n', 'xxxxxxxxxxxxooooooox\n', 'oxxxxxxxxxxxxxoooooo\n'] Imagine that this string is a theater where you have to find all free single seats. x = seats sold out o = seats free With “free single seat” I mean seats that (1) has no free neighbors (no multiple “o”-s) and (2) not located at the beginning or end of a row (as eg. in the last line). I tried the following RegEx pattern: [^o]o[^o] Does not work because it can’t find all single “o”, eg. in “xoxoxox” it misses the second “o”. Any idea for solution?