Fast match() function