The TL;DR is, RegEx behaves slightly differently in each programming language. For example, if and how newlines are matched.
There are three main flavors of RegEx: POSIX, Extended, and PCRE. Most UNIX tools implement either POSIX or Extended. Most Programming languages implement PCRE. Some programs (/cough vim/) just make up their own regex langauge as they go.
[1] https://stackoverflow.com/questions/159118/how-do-i-match-an...