I don't know whether you have noticed that your pattern has many errors. Firstly, there is no need to use a subpattern, the outside pair of parentheses can completely be droped. Secondly, if you want to strip spaces next to '(' and ')', you need to use \s+ at both start and end sides, '[\s.]' is another mistake. At last, the content within '(' and ')', there is space in string '180 degrees' so a character represent white space also exists in character class, you can use either ' ' or '\s'. So the right pattern should like this '/\s+\([\w\s-]\)\s+/' or '/\s+\([\w -]\)\s+/'.