If you have homebrew you can just install the 'gnu-sed' package and then change the function to call 'gsed' instead.
Here's my terribly hackish version for BSD userlands (briefly tested on FreeBSD, may work on OS X):
#!/bin/sh
eg () {
man $1 | grep '^E.EX.XA' -A 1000 | grep '^[A-Z]' -m 2 -B 1000 -A 0 | sed '$d' | $PAGER
}
eg $1
Could anyone contribute a version for OSX?