The following regex will search for an item and its price on a shop page: Code (Text): <div class="text" id="{CB}" style="font-family: monospace;"><ol><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">(?<=(se ))[A-Za-z0-9 ,]+(?=(\?\\n))</li></ol></div> For those who don't know what a regex is, it is a complicated syntax for recognizing patterns in text. For example, a regex could be used to pick out e-mail addresses out of a block of text, just as this regex picks out a particular pattern that represents an item and its price. For example, using it to search on the following page (Tiki shop, I have cut out the irrelevant source): Code (Text): <div class="text" id="{CB}" style="font-family: monospace;"><ol><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> </li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><form name='refreshform' method='get'><input type='hidden' name='type' value='shop'><input type='hidden' name='obj_type' value='21'></form><center><a href='objects.phtml?type=shop&obj_type=21'><img src='http://images.neopets.com/shopkeepers/21.gif' width=150 height=150 border=0></a><br><b>Tiki Tack</b><br>Get your Mystery Island Merchandise here!<br></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> Click <a href='/island/index.phtml'><b>here</b></a> to return to Mystery Island.<br><p><table width=300 border=1 cellpadding=6 cellspacing=0 align=center><tr><td width=300 align=center><img src='http://images.neopets.com/battledome/opponent_pics/23.gif' width=100 height=100 border=1><p><b>NEW BATTLEDOME CHALLENGER!!!</b><p><b>Tiki Tack</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">Man</b> will be waiting for you in the <a href='/battledome/battledome.phtml?type=oneplayer&subtype=info'><b>BATTLEDOME</b></a>!!!<p><i>Tired of selling tacky merchandise on Mystery Island, this tribal shopkeeper sometimes ventures to the Battle Dome to try his luck!</i></td></tr></table><p></center><P><div align="center">Neopian Inflation is currently at <b>2.31%</b><br></div><BR><BR><FORM name="items_for_sale" method="post"><TABLE align="center" cellpadding="4" border="0"><TR><TD width="120" align="center" valign="top"><A href="haggle.phtml?obj_info_id=7447&stock_id=442793443&g=3" onClick="this.href='haggle.phtml?ob'+'j_info_id=7447&stock_id=442793443&brr=1366';if (!confirm('Are you sure you wish to purchase Cub Tooth at 1,005 NP?\n\n(you can still haggle to push the price lower!)')) { return false; }"><IMG src="http://images.neopets.com/items/tiki_cubtooth.gif" width="80" height="80" alt="Teenage islanders traditionally collect these and give them to their sweethearts as gifts." title="Teenage islanders traditionally collect these and give them to their sweethearts as gifts." border="1"></A><BR><B>Cub Tooth</B><BR>7 in stock<BR>Cost: 1,005 NP<BR><BR></TD><TD width="120" align="center" valign="top"><A href="haggle.phtml?obj_info_id=20342&stock_id=149678467&g=3" onClick="this.href='haggle.phtml?ob'+'j_info_id=20342&stock_id=149678467&brr=1366';if (!confirm('Are you sure you wish to purchase Blue Grass Skirt at 1,013 NP?\n\n(you can still haggle to push the price lower!)')) { return false; }"><IMG src="http://images.neopets.com/items/gadgadpuzzle_skirt2.gif" width="80" height="80" alt="Just the thing for a great Mystery Island tiki party! Now all you need is some tasty fruit, and a limbo dancing competition!" title="Just the thing for a great Mystery Island tiki party! Now all you need is some tasty fruit, and a limbo dancing competition!" border="1"></A><BR><B>Blue Grass Skirt</B><BR>1 in stock<BR>Cost: 1,013 NP<BR><BR></TD><TD width="120" align="center" valign="top"><A href="haggle.phtml?obj_info_id=7437&stock_id=951898021&g=3" onClick="this.href='haggle.phtml?ob'+'j_info_id=7437&stock_id=951898021&brr=1366';if (!confirm('Are you sure you wish to purchase Bottle of Black Sand at 268 NP?\n\n(you can still haggle to push the price lower!)')) { return false; }"><IMG src="http://images.neopets.com/items/tiki_blksand.gif" width="80" height="80" alt="This special black sand is found in very limited quantity around the base of the volcano on the island." title="This special black sand is found in very limited quantity around the base of the volcano on the island." border="1"></A><BR><B>Bottle of Black Sand</B><BR>2 in stock<BR>Cost: 268 NP<BR><BR></TD><TD width="120" align="center" valign="top"><A href="haggle.phtml?obj_info_id=34712&stock_id=340021976&g=3" onClick="this.href='haggle.phtml?ob'+'j_info_id=34712&stock_id=340021976&brr=1366';if (!confirm('Are you sure you wish to purchase Carved Tiki Mug at 1,355 NP?\n\n(you can still haggle to push the price lower!)')) { return false; }"><IMG src="http://images.neopets.com/items/tiki_carved_mug.gif" width="80" height="80" alt="Now, no matter what you are drinking you will think of Mystery Island." title="Now, no matter what you are drinking you will think of Mystery Island." border="1"></A><BR><B>Carved Tiki Mug</B><BR>2 in stock<BR>Cost: 1,355 NP<BR><BR></TD><TD width="120" align="center" valign="top"><A href="haggle.phtml?obj_info_id=7444&stock_id=522774907&g=3" onClick="this.href='haggle.phtml?ob'+'j_info_id=7444&stock_id=522774907&brr=1366';if (!confirm('Are you sure you wish to purchase Oak Wish Stick at 2,373 NP?\n\n(you can still haggle to push the price lower!)')) { return false; }"><IMG src="http://images.neopets.com/items/tac_oakwishstick.gif" width="80" height="80" alt="Even more powerful then the cherry wish stick, the oak wish stick is cut on the last full moon of the year from a single oak tree which grows on the island." title="Even more powerful then the cherry wish stick, the oak wish stick is cut on the last full moon of the year from a single oak tree which grows on the island." border="1"></A><BR><B>Oak Wish Stick</B><BR>13 in stock<BR>Cost: 2,373 NP<BR><BR></TD></TR><TR><TD width="120" align="center" valign="top"><A href="haggle.phtml?obj_info_id=7435&stock_id=480995293&g=3" onClick="this.href='haggle.phtml?ob'+'j_info_id=7435&stock_id=480995293&brr=1366';if (!confirm('Are you sure you wish to purchase Bottle of Green Sand at 271 NP?\n\n(you can still haggle to push the price lower!)')) { return false; }"><IMG src="http://images.neopets.com/items/tiki_greensand.gif" width="80" height="80" alt="From the lush western shores of the island, this sand is reputed to make anything planted in it grow twice as big. It is just a rumour though." title="From the lush western shores of the island, this sand is reputed to make anything planted in it grow twice as big. It is just a rumour though." border="1"></A><BR><B>Bottle of Green Sand</B><BR>7 in stock<BR>Cost: 271 NP<BR><BR></TD><TD width="120" align="center" valign="top"><A href="haggle.phtml?obj_info_id=7452&stock_id=226557893&g=3" onClick="this.href='haggle.phtml?ob'+'j_info_id=7452&stock_id=226557893&brr=1366';if (!confirm('Are you sure you wish to purchase Official Coconut Mask at 3,329 NP?\n\n(you can still haggle to push the price lower!)')) { return false; }"><IMG src="http://images.neopets.com/items/tiki_officialcoconutmask.gif" width="80" height="80" alt="The only mask that is sanctioned by the Island Committee for Quality Souvenirs, with one of these masks you can join the natives in one of their many celebrations." title="The only mask that is sanctioned by the Island Committee for Quality Souvenirs, with one of these masks you can join the natives in one of their many celebrations." border="1"></A><BR><B>Official Coconut Mask</B><BR>14 in stock<BR>Cost: 3,329 NP<BR><BR></TD><TD width="120" align="center" valign="top"><A href="haggle.phtml?obj_info_id=7430&stock_id=571179173&g=3" onClick="this.href='haggle.phtml?ob'+'j_info_id=7430&stock_id=571179173&brr=1366';if (!confirm('Are you sure you wish to purchase Volcanic Rock at 264 NP?\n\n(you can still haggle to push the price lower!)')) { return false; }"><IMG src="http://images.neopets.com/items/tiki_rock.gif" width="80" height="80" alt="Not your ordinary rock. These volcanic rocks come from the sacred volcano. The natives believe that the volcano is the source of all life on the island." title="Not your ordinary rock. These volcanic rocks come from the sacred volcano. The natives believe that the volcano is the source of all life on the island." border="1"></A><BR><B>Volcanic Rock</B><BR>13 in stock<BR>Cost: 264 NP<BR><BR></TD><TD width="120" align="center" valign="top"><A href="haggle.phtml?obj_info_id=7448&stock_id=65870109&g=3" onClick="this.href='haggle.phtml?ob'+'j_info_id=7448&stock_id=65870109&brr=1366';if (!confirm('Are you sure you wish to purchase Hularoo at 1,646 NP?\n\n(you can still haggle to push the price lower!)')) { return false; }"><IMG src="http://images.neopets.com/items/tiki_hularoo.gif" width="80" height="80" alt="Amuse your friends and family with this hula dancing Blumaroo. " title="Amuse your friends and family with this hula dancing Blumaroo. " border="1"></A><BR><B>Hularoo</B><BR>14 in stock<BR>Cost: 1,646 NP<BR><BR></TD><TD width="120" align="center" valign="top"><A href="haggle.phtml?obj_info_id=7431&stock_id=574503301&g=3" onClick="this.href='haggle.phtml?ob'+'j_info_id=7431&stock_id=574503301&brr=1366';if (!confirm('Are you sure you wish to purchase Sandals at 338 NP?\n\n(you can still haggle to push the price lower!)')) { return false; }"><IMG src="http://images.neopets.com/items/tiki_sandals.gif" width="80" height="80" alt="Handmade by the finest island craftsmen, who put hours of labour into each and every sandal. Guaranteed to keep your feet from the burning hot island sand." title="Handmade by the finest island craftsmen, who put hours of labour into each and every sandal. Guaranteed to keep your feet from the burning hot island sand." border="1"></A><BR><B>Sandals</B><BR>15 in stock<BR>Cost: 338 NP<BR><BR></TD></TR><TR><TD width="120" align="center" valign="top"><A href="haggle.phtml?obj_info_id=7432&stock_id=120917177&g=3" onClick="this.href='haggle.phtml?ob'+'j_info_id=7432&stock_id=120917177&brr=1366';if (!confirm('Are you sure you wish to purchase Toy Sail Boat at 264 NP?\n\n(you can still haggle to push the price lower!)')) { return false; }"><IMG src="http://images.neopets.com/items/tiki_boat.gif" width="80" height="80" alt="Handcarved by the island elders, these traditional gifts are given to those who show expertise in the art of sailing." title="Handcarved by the island elders, these traditional gifts are given to those who show expertise in the art of sailing." border="1"></A><BR><B>Toy Sail Boat</B><BR>6 in stock<BR>Cost: 264 NP<BR><BR></TD><TD width="120" align="center" valign="top"><A href="haggle.phtml?obj_info_id=7455&stock_id=125679438&g=3" onClick="this.href='haggle.phtml?ob'+'j_info_id=7455&stock_id=125679438&brr=1366';if (!confirm('Are you sure you wish to purchase Surfboard Keyring at 317 NP?\n\n(you can still haggle to push the price lower!)')) { return false; }"><IMG src="http://images.neopets.com/items/tiki_surfboardkeyring.gif" width="80" height="80" alt="Surfs always up when you keep your keys on one of these wonderful keyrings!" title="Surfs always up when you keep your keys on one of these wonderful keyrings!" border="1"></A><BR><B>Surfboard Keyring</B><BR>11 in stock<BR>Cost: 317 NP<BR><BR></TD><TD width="120" align="center" valign="top"><A href="haggle.phtml?obj_info_id=7454&stock_id=399453730&g=3" onClick="this.href='haggle.phtml?ob'+'j_info_id=7454&stock_id=399453730&brr=1366';if (!confirm('Are you sure you wish to purchase Souvenir Magnet at 4,558 NP?\n\n(you can still haggle to push the price lower!)')) { return false; }"><IMG src="http://images.neopets.com/items/tiki_souvenirmagnet.gif" width="80" height="80" alt="Keep your island pass safe on the fridge with this souvenir magnet featuring one of the island natives." title="Keep your island pass safe on the fridge with this souvenir magnet featuring one of the island natives." border="1"></A><BR><B>Souvenir Magnet</B><BR>28 in stock<BR>Cost: 4,558 NP<BR><BR></TD><TD width="120" align="center" valign="top"><A href="haggle.phtml?obj_info_id=31713&stock_id=835493451&g=3" onClick="this.href='haggle.phtml?ob'+'j_info_id=31713&stock_id=835493451&brr=1366';if (!confirm('Are you sure you wish to purchase Plain Wooden Bowl at 347 NP?\n\n(you can still haggle to push the price lower!)')) { return false; }"><IMG src="http://images.neopets.com/items/tiki_wooden_bowl.gif" width="80" height="80" alt="Store fruit, shells, or your Neopoints in this plain wooden bowl." title="Store fruit, shells, or your Neopoints in this plain wooden bowl." border="1"></A><BR><B>Plain Wooden Bowl</B><BR>5 in stock<BR>Cost: 347 NP<BR><BR></TD><TD width="120" align="center" valign="top"><A href="haggle.phtml?obj_info_id=7445&stock_id=913294111&g=3" onClick="this.href='haggle.phtml?ob'+'j_info_id=7445&stock_id=913294111&brr=1366';if (!confirm('Are you sure you wish to purchase Coconut God Souvenir at 971 NP?\n\n(you can still haggle to push the price lower!)')) { return false; }"><IMG src="http://images.neopets.com/items/tiki_coconutgodsouvenir.gif" width="80" height="80" alt="These items are hand carved from local rock to represent the Coconut God, protector of the Coconut People." title="These items are hand carved from local rock to represent the Coconut God, protector of the Coconut People." border="1"></A><BR><B>Coconut God Souvenir</B><BR>19 in stock<BR>Cost: 971 NP<BR><BR></TD></TR><TR><TD width="120" align="center" valign="top"><A href="haggle.phtml?obj_info_id=7453&stock_id=10201084&g=3" onClick="this.href='haggle.phtml?ob'+'j_info_id=7453&stock_id=10201084&brr=1366';if (!confirm('Are you sure you wish to purchase Rustic Kougra Plushie at 1,537 NP?\n\n(you can still haggle to push the price lower!)')) { return false; }"><IMG src="http://images.neopets.com/items/tiki_plushcub.gif" width="80" height="80" alt="Modeled after one of the native species on the island, these plush cubs dont squeak - they RRoar!" title="Modeled after one of the native species on the island, these plush cubs dont squeak - they RRoar!" border="1"></A><BR><B>Rustic Kougra Plushie</B><BR>4 in stock<BR>Cost: 1,537 NP<BR><BR></TD><TD width="120" align="center" valign="top"><A href="haggle.phtml?obj_info_id=7441&stock_id=359445866&g=3" onClick="this.href='haggle.phtml?ob'+'j_info_id=7441&stock_id=359445866&brr=1366';if (!confirm('Are you sure you wish to purchase Clay Vase at 595 NP?\n\n(you can still haggle to push the price lower!)')) { return false; }"><IMG src="http://images.neopets.com/items/tac_clayvase.gif" width="80" height="80" alt="Containing a double band of green sand, these vases will keep your blossoms fresh twice as long as any other vase." title="Containing a double band of green sand, these vases will keep your blossoms fresh twice as long as any other vase." border="1"></A><BR><B>Clay Vase</B><BR>15 in stock<BR>Cost: 595 NP<BR><BR></TD><TD width="120" align="center" valign="top"><A href="haggle.phtml?obj_info_id=7436&stock_id=705243647&g=3" onClick="this.href='haggle.phtml?ob'+'j_info_id=7436&stock_id=705243647&brr=1366';if (!confirm('Are you sure you wish to purchase Bottle of Blue Sand at 281 NP?\n\n(you can still haggle to push the price lower!)')) { return false; }"><IMG src="http://images.neopets.com/items/tiki_bluesand.gif" width="80" height="80" alt="This azure coloured sand comes from the cool northern shores of the island. It is used by natives to dye their clothes." title="This azure coloured sand comes from the cool northern shores of the island. It is used by natives to dye their clothes." border="1"></A><BR><B>Bottle of Blue Sand</B><BR>18 in stock<BR>Cost: 281 NP<BR><BR></TD><TD width="120" align="center" valign="top"><A href="haggle.phtml?obj_info_id=7456&stock_id=89322448&g=3" onClick="this.href='haggle.phtml?ob'+'j_info_id=7456&stock_id=89322448&brr=1366';if (!confirm('Are you sure you wish to purchase Visor at 1,727 NP?\n\n(you can still haggle to push the price lower!)')) { return false; }"><IMG src="http://images.neopets.com/items/tiki_visor.gif" width="80" height="80" alt="For fair skinned travellers. Dont get caught on the beach without one of these visors." title="For fair skinned travellers. Dont get caught on the beach without one of these visors." border="1"></A><BR><B>Visor</B><BR>19 in stock<BR>Cost: 1,727 NP<BR><BR></TD><TD width="120" align="center" valign="top"><A href="haggle.phtml?obj_info_id=7451&stock_id=770298238&g=3" onClick="this.href='haggle.phtml?ob'+'j_info_id=7451&stock_id=770298238&brr=1366';if (!confirm('Are you sure you wish to purchase Neopets Beach Ball at 954 NP?\n\n(you can still haggle to push the price lower!)')) { return false; }"><IMG src="http://images.neopets.com/items/tiki_neopetsbeachball.gif" width="80" height="80" alt="You cant go to the beach without one of these colourful beach balls!" title="You cant go to the beach without one of these colourful beach balls!" border="1"></A><BR><B>Neopets Beach Ball</B><BR>3 in stock<BR>Cost: 954 NP<BR><BR></TD></TR><TR><TD width="120" align="center" valign="top"><A href="haggle.phtml?obj_info_id=7446&stock_id=204240034&g=3" onClick="this.href='haggle.phtml?ob'+'j_info_id=7446&stock_id=204240034&brr=1366';if (!confirm('Are you sure you wish to purchase Coconut Keyring at 337 NP?\n\n(you can still haggle to push the price lower!)')) { return false; }"><IMG src="http://images.neopets.com/items/tiki_coconutkeyring.gif" width="80" height="80" alt="Never lose your keys again with this handy keyring. Not only does it hold your keys, it pokes you in the leg to let you know its still in your pocket!" title="Never lose your keys again with this handy keyring. Not only does it hold your keys, it pokes you in the leg to let you know its still in your pocket!" border="1"></A><BR><B>Coconut Keyring</B><BR>9 in stock<BR>Cost: 337 NP<BR><BR></TD><TD width="120" align="center" valign="top"><A href="haggle.phtml?obj_info_id=7443&stock_id=725372797&g=3" onClick="this.href='haggle.phtml?ob'+'j_info_id=7443&stock_id=725372797&brr=1366';if (!confirm('Are you sure you wish to purchase Acorn Toy at 1,345 NP?\n\n(you can still haggle to push the price lower!)')) { return false; }"><IMG src="http://images.neopets.com/items/tac_acorntoy.gif" width="80" height="80" alt="These cute little toys are made in large numbers by island children and are given as presents at special occasions all year long." title="These cute little toys are made in large numbers by island children and are given as presents at special occasions all year long." border="1"></A><BR><B>Acorn Toy</B><BR>12 in stock<BR>Cost: 1,345 NP<BR><BR></TD><TD width="120" align="center" valign="top"><A href="haggle.phtml?obj_info_id=7429&stock_id=186505218&g=3" onClick="this.href='haggle.phtml?ob'+'j_info_id=7429&stock_id=186505218&brr=1366';if (!confirm('Are you sure you wish to purchase Pickled Olives at 261 NP?\n\n(you can still haggle to push the price lower!)')) { return false; }"><IMG src="http://images.neopets.com/items/tiki_olives.gif" width="80" height="80" alt="Hand picked by young natives, these are a rare delicacy. Even for the islanders, who consume large numbers of them at their annual olive festival." title="Hand picked by young natives, these are a rare delicacy. Even for the islanders, who consume large numbers of them at their annual olive festival." border="1"></A><BR><B>Pickled Olives</B><BR>9 in stock<BR>Cost: 261 NP<BR><BR></TD><TD width="120" align="center" valign="top"><A href="haggle.phtml?obj_info_id=34711&stock_id=870227071&g=3" onClick="this.href='haggle.phtml?ob'+'j_info_id=34711&stock_id=870227071&brr=1366';if (!confirm('Are you sure you wish to purchase Lava Stone Necklace at 1,052 NP?\n\n(you can still haggle to push the price lower!)')) { return false; }"><IMG src="http://images.neopets.com/items/tiki_islandnecklace.gif" width="80" height="80" alt="This pretty necklace is made with lava stones." title="This pretty necklace is made with lava stones." border="1"></A><BR><B>Lava Stone Necklace</B><BR>4 in stock<BR>Cost: 1,052 NP<BR><BR></TD></TABLE></FORM></li></ol></div> Will return the following set of matches: Code (Text): <div class="text" id="{CB}" style="font-family: monospace;"><ol><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">Cub Tooth at 1,005 NP</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">Blue Grass Skirt at 1,013 NP</li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">Bottle of Black Sand at 268 NP</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">Etc for all the items on the page</li></ol></div> From here you can split a string along " at " and finally chop off the last 3 letters and you have a 2d array of an items name and its price. Regexs are incredibly useful, and this is just a simple example of what they are capable of doing.
Hey ryan, I was interested int learning up on regex, do you know any good sources, be specific, about how to do regex
I just copied and pasted this entire site and printed it off: http://www.regular-expressions.info/ After reading it a few times, I can put together any of the kinds of regular expressions that I think I will need, although I am only scratching the surface. I know that it is possible to make a regex that will return the item name and price like this " Item Name|4323", I just have no idea how. Essentialy its just a normal find function with some extra stuff. Ex: "Gr[ae]y" will match "Gray" or "Grey" "Gr[a-z]y" Will match "Gray" "Grby" "Grzy" ... The + operator will allow a repeating series: "He+llo" will match Hello, Heello, Heeello, Heeeello... Together... "Hi[a-z]+," will match anything that starts with a "Hi", ends with a "," and has only lower case letters between the two. I also added lookback and lookforward into my regex (Counts as part of the search, but isn't returned as a result). It looks way more complicated than it really is.