Postgresql Find Substring Javascript Function Return