var substringMatcher = function(strs) { return function findMatches(q, cb) { var matches, substringRegex; // an array that will be populated with substring matches matches = []; // regex used to determine if a string contains the substring `q` substrRegex = new RegExp(q, 'i'); // iterate through the pool of strings and for any string that // contains the substring `q`, add it to the `matches` array $.each(strs, function(i, str) { if (substrRegex.test(str)) { matches.push(str); } }); cb(matches); }; }; var products = ['1 The Platt, The Platt, Wadebridge, Cornwall','1, The Platt, Wadebridge, Cornwall','10 Central Square, Newquay, Cornwall','2 Bank Place, Falmouth, Cornwall','2 Carminnow Road Industrial Estate, Bodmin, Cornwall','2 Duke Street, Truro, Cornwall','23 East Street, Newquay, Cornwall','26 - 26A Courtenay Street, Newton Abbot, Devon','26 Fore Street, Redruth, Cornwall','27-31 Fore Street, Bodmin, Cornwall','28 Penpol Terrace, Hayle, Cornwall','29-31 Fore Street, Bodmin, Cornwall','3 Fore Street, Newquay, Cornwall','3, The Platt, Wadebridge, Cornwall','35 Killigrew Street, Falmouth, Cornwall','4 Boscawen Road, Perranporth, Cornwall','42 Market Street, Falmouth, Cornwall','46 East Street, Newquay, Cornwall','55, Fore Street, Redruth, Cornwall','57, Little Castle Street, Truro','60A \u0026 60B East Street, Newquay, Cornwall','7 The Moor, Falmouth, Cornwall','8 - 10 Molesworth Street, Wadebridge, Cornwall','8 Coinagehall Street, Helston, Cornwall','8 Duke Street, Truro, Cornwall','8 St Mary\u0027s Street, Truro, Cornwall','9 Lemon Street, Truro, Cornwall','9A Commercial Square, Camborne, Cornwall','Agar Way, Redruth, Cornwall','Arwenack Avenue, Falmouth, Cornwall','Bar Restaurant Opportunity, Queens Buildings, 4 Promenade, Penzance, Cornwall','Beach Restaurant, Sennen, Penzance, Cornwall','Bossiney Road, Tintagel, Cornwall','Bridge House, The Bridge, Boscastle, Cornwall','Bunters, 58 Little Castle Street, Truro, Cornwall','Cakebreads, Canton Street, Gorran Haven, St. Austell, Cornwall','Confidential Boutique Guest House, Truro, Cornwall','Confidential Holiday Park, Near Cornwall Coast, Cornwall','Confidential Leasehold Pub, 26 Falmouth Road, Truro, Cornwall','Convenience Store Cornwall, Rock House, Fore Street, Polperro, Looe, Cornwall','Corner Deli, 12 Fore Street, Porthleven, Helston, Cornwall','Cornish Arms, 64 Fore Street, Constantine, Falmouth, Cornwall','First Floor Chiltern House, City Road, Truro, Cornwall','First Floor Offices, The Old Stables, Liskey Hill, Perranporth, Cornwall','Five Pilchards Inn, Porthallow, Lizard, Cornwall','Former Shipwreck Treasure Museum, The Merchants Of Charlestown, Quay Road, Charlestown, St. Austell, Cornwall','Garages At , Loe Bar Road, Porthleven, Helston, Cornwall','Harbour View (Leasehold), 24 Arwenack Street, Falmouth, Cornwall','High Street, St. Ives, Cornwall','Higher Trevaskis Caravan \u0026 Camping Park, Gwinear Road, Connor Downs, Hayle, Cornwall','Italian Cafe, Blue Mill, Station Road, Fowey, Cornwall','Kenegie Manor Holiday Park, Gulval, Penzance, Cornwall','Kings Arms Hotel, 3 Broad Street, Penryn, Cornwall','Koffiji Cafe \u0026 Bar (Leasehold), Tidemill House, Discovery Quay, Falmouth, Cornwall','La Bocca, Higher Market Street, Looe, Cornwall','Land Adjacent To Blackwater CP School, North Hill, Blackwater, Truro, Cornwall','Lanner Auction Room, Church Row, Lanner, Redruth, Cornwall','Lansdowne Guest House, 42 Clinton Road, Redruth, Cornwall','Lemon Chapel, William Street, Truro, Cornwall','Llawnroc Hotel, Chute Lane, Gorran Haven, St. Austell, Cornwall','Lloyds Bank, The Parade, Liskeard, Cornwall','Lodge 16 , Woodland Lodges, The Cornwall Hotel Pentewan Road, Tregorrick, St. Austell, Cornwall','Lodge 16 , Woodland Lodges, The Cornwall Hotel Pentewan Road, Tregorrick, St. Austell, Cornwall','Mexico Inn, Longrock, Penzance, Cornwall','Moor Wood Campsite, Hill Road, North Hill, Minehead, Somerset','Morfa Hall, Cliff Road, Newquay, Cornwall','Mustard Tree, St. Ives Road, Carbis Bay, St. Ives, Cornwall','Navy Inn, Queen Street, Penzance, Cornwall','Oasis House \u0026 Apartment, Dracaena Avenue, Falmouth, Cornwall','Office Building 2 , Liddicoat Road, Restormel Industrial Estate, Lostwithiel, Cornwall','Office Suites, Norfolk House, 16-17 Lemon Street, Truro, Cornwall','Old Customs House First Floor, Wharf Road, St. Ives, Cornwall','Old Mill Guest House \u0026 Bistro, Little Petherick, Padstow, Cornwall','Olive Grove Bistro, Barras Moor Farm, Barras Moor, Perranarworthal, Falmouth, Cornwall','One Polkirt Hill Restaurant, 1 Polkirt Hill, Mevagissey, Cornwall','Penryn House, The Coombes, Polperro, Cornwall','Piran House, Nettles Hill, Redruth, Cornwall','Plot 5, Treliske Industrial Estate, Treliske, Truro, Cornwall','Radjel Inn, Boscaswell Terrace, Pendeen, Penzance, Cornwall','Rising Sun, Altarnun, Launceston, Cornwall','Rosario B\u0026B And Tea Garden, The Square, Marazion, Cornwall','Rosario, The Square, Marazion, Cornwall','Roseland \u0026 Pendennis House, 1A Trescobeas Road, Falmouth, Cornwall','Royal Oak, Perranwell Station, Truro, Cornwall','Sabre Court, Windsor Terrace, Falmouth, Cornwall','Second Floor Offices Piran House, Nettles Hill, Redruth, Cornwall','Slades House Country Inn, Sladesbridge, Wadebridge, Cornwall','Slipway, Middle Street, Port Isaac, Cornwall','Source Kitchen, 6 The Digey, St. Ives, Cornwall','Stepping Stones, 1 Liskey Hill, Perranporth, Cornwall','Tackle Shop, West Wharf, Mevagissey, St. Austell, Cornwall','The Bakehouse, Chapel Street, Penzance, Cornwall','The Cornish Vegan, 15 Kenwyn Street, Truro, Cornwall','The Old Chapel, St. Clement Street, Truro, Cornwall','The Pantry, 17 Fore Street, St. Ives, Cornwall','The Shop, Grenville Road Old Hill, Falmouth, Cornwall','The Square Industrial Units, Grampound Road, Cornwall','Thurlestone Guest House, St. Ives Road, Carbis Bay, St. Ives, Cornwall','Tideline Cafe, 2 The Square, Portreath, Redruth, Cornwall','Torwood House, Alexandra Road, Penzance, Cornwall','Tower Park Caravan \u0026 Camping, St. Buryan, Penzance, Cornwall','Tregonning Burrows \u0026 Morvargh, Balwest, Ashton, Helston, Cornwall','Treveague Farm Cottages, Nr Gorran Haven, St. Austell, Cornwall','Tuckingmill Hotel, 109 Pendarves Street, Tuckingmill, Camborne, Cornwall','Unit 1, Travail Business Park, Normandy Way, Bodmin, Cornwall','Unit 10C, Threemilestone Industrial Estate, Threemilestone, Truro, Cornwall','Unit 14, Threemilestone Industrial Estate, Threemilestone, Truro, Cornwall','Unit 2 Seafood Trading, Victoria Business Park, Penstraze Lane, Roche, St. Austell, Cornwall','Unit 2, Cathedral Compound, Heron Way, Newham, Truro, Cornwall','Unit 2, Travail Business Park, Normandy Way, Bodmin, Cornwall','Unit 2A, Cligga Head Industrial Estate, St. Georges Hill, Perranporth, Cornwall','Unit 2C, Willis Vean, Mullion, Helston, Cornwall','Unit 3 \u0026 4, Station Road Industrial Estate, Perranporth, Cornwall','Unit 3, Tinners Court, Back Quay, Truro, Cornwall','Unit 3, Woods Browning Industrial Estate, Respryn Road, Bodmin, Cornwall','Unit 39-41A, Barncoose Industrial Estate, Barncoose, Redruth, Cornwall','Unit 3F, Trewellard Industrial Estate, Pendeen, Penzance, Cornwall','Unit 40, Threemilestone Industrial Estate, Threemilestone, Truro, Cornwall','Unit 5D, Falmouth Business Park, Bickland Water Road, Falmouth, Cornwall','Unit 6, Leo Cub Industrial Centre, Kernick Road, Penryn, Cornwall','Unit B1, Walker Business Park, Threemilestone Industrial Estate, Threemilestone, Truro, Cornwall','Victoria Inn, Perranuthnoe, Penzance, Cornwall','West Dry Holiday Cottages, Carbis Wharf, Roche, St. Austell, Cornwall','White Pyramid, Trewoon, St. Austell, Cornwall','Woodland Lodges, The Cornwall Hotel \u0026 Spa, Pentewan Road, St. Austell, Cornwall' ]; $('#our-products .typeahead').typeahead({ hint: true, highlight: true, minLength: 1 }, { name: 'products', limit: 10, source: substringMatcher(products) });