Added regex match algorithm