Parsing pricerunner.com results via regular expression.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • addisonp
    New Member
    • Jul 2007
    • 2

    #16
    Originally posted by ojsimon
    sorry, how do i use preg match and replace could you tell me any sites where i can learn how to use them to fulfill my request previously
    Thanks

    Here's a simple example on how to use those functions:

    $pattern = "/[^a-zA-Z0-9]/";
    $replacement = " _";
    $replaced_name= preg_replace($p attern,$replace ment,$original_ name);

    This example shows you the pattern you are searching for, in this case, anything that is not a letter or number and replacing it with an underscore. It takes an original name variable (i.e. Tac k#y) and after it goes through preg_replace returns something like "Tac_k_y"

    Hope that helps

    Comment

    • pbmods
      Recognized Expert Expert
      • Apr 2007
      • 5821

      #17
      Heya, Olie.

      A blank page means that your script is probably generating errors.

      Check out this article.

      Comment

      • ojsimon
        New Member
        • May 2007
        • 59

        #18
        Originally posted by pbmods
        Heya, Olie.

        A blank page means that your script is probably generating errors.

        Check out this article.

        Sorry for very late reply
        but with echo $matches the script retuns 'array' and with echo $html it returns the whole page.
        How can i fix this?

        [PHP]<?php
        $html = file_get_conten ts('http://pricerunner.co. uk/search?q=ipod') ;
        preg_match_all( '/(?<=<span class="listpric e">£)\d+\.\d {2}/', $html, $matches);

        echo $html;
        ?>[/PHP]
        Thanks

        Comment

        • pbmods
          Recognized Expert Expert
          • Apr 2007
          • 5821

          #19
          Try [code=php]print_r($matche s);[/code]

          Comment

          Working...