Replaced the regExp and added a foreach loop. Removed style

https://github.com/GigaOM/gigaom/issues/5083

I tested it using the examples here https://github.com/GigaOM/gigaom/issues/4979 
they all looked good
Note spacing and brace style rules throughout.