Finalize new API,  more examples

Also fix issue 9579.
address review comments
Merge pull request #1470 from blackwhale/regex-new-api-2

Finalize new API, more examples