Made regex fucntion genralizble