Implements function to contain the regex parsing