implement regex template parser