Regular expression needed

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Regular expression needed

    this is my question:

    suppose i have a html element

    <a href="value1">value2</a>


    can any give me the regular expression to get value1 and value2 from the element?

    thanks really much appreciated

    #2
    <a href="value1&val=value2">value2</a>

    Comment


      #3
      thanks for trying but thats not what am taking about, i am talking removing the the value of the attributes from the element

      so if i have <a href="value1">value2</a>

      i want to get value1 and value2 from the string using some preg_match or some preg_replace
      its the regular expression that i dont knw

      Comment


        #4
        $value1 = explode("\"", $all_html_here);
        $value1 = $value1[1];

        Like this?
        mysterio.al - programming is a functional art

        Comment


          #5
          $General_value = array("value_1,"value_2");
          $Call_value = rand(0,count($General_value)-1);
          include($General_value[$Call_value]);

          like this simple value call? .... Hmm I cant get u mate or u mean what?

          Comment


            #6
            PHP Code:
            $s "<a href='value1'>value2</a>";
            preg_match("/<a href=[\"|'](.*)[\"|']>(.*)<\/a>/i"$s$m);
            print_r($m); 
            output will be:
            Code:
            Array
            (
                [0] => <a href='value1'>value2</a>
                [1] => value1
                [2] => value2
            )
            Advertise your mobile site for FREE with AdTwirl

            Comment


              #7
              thank you very much gumslone, that is what i am looking for, thanks alot

              Added after 44 minutes:

              Code:
              <?php
              echo '<br/> link';
              
              $s = '<a href="value1">value2</a>';
              preg_match("/<a href=[\"|'](.*)[\"|']>(.*)<\/a>/i", $s, $m);
              print_r($m);
              
              echo '<br/> image';
              
              
              $image = '<img src="value1" alt="value2"/>';
              
              preg_match("/<img src=[\"|'](.*)[\"|] alt=[\"|'](.*)[\"|']\/>/i", $image, $t);
              
              print_r($t);
              
              echo '<br/> image link';
              
              $imagelink = '<a href="link"><img src="image source" alt="image title"/></a>';
              
              preg_match("/<a href=[\"|'](.*)[\"|']><img src=[\"|'](.*)[\"|] alt=[\"|'](.*)[\"|']\/><\/a>/i", $imagelink, $v);
              
              print_r($v);
              
              
              
              
              
              
              ?>
              Last edited by antony2kx; 24.09.10, 01:18.

              Comment


                #8
                What abt other commenter?

                Comment


                  #9
                  Originally posted by mob_mate View Post
                  What abt other commenter?
                  There are some users here, who made half questions, then let us guess what the question is and find a right answer. But how?
                  mysterio.al - programming is a functional art

                  Comment

                  Working...
                  X