added conditional logic (can be improved for other versions of bsd/solar...

updated the explain tool for osx support (BSD sed uses -E rather than -r for extended regex)