make sure regex match has results before using element 0 to prevent error
added ability to use a function as a data source