php question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JDog
    Confirmed User
    • Feb 2003
    • 7453

    #1

    php question

    i'm a php programmer, just never really messed with regular expressions. now i'm running into a problem I'm trying to creat a regular expression that will read a line of text from a file and if it has href=someurl. But nothing is working. here is what I hvae so far.
    PHP Code:
    preg_match("/href='(.*)'/", $testing, $testing2); 
    
    but doesn't seem to work if the $testing variable has:
    PHP Code:
    $testing "<a href=james.com>" 
    
    Thanks in advance for any help

    jDoG
    NSCash now powering ReelProfits.com
    ALSO FEATURING: NSCash.com :: SoloDollars.com :: ReelProfits.com :: BiminiBucks.com :: VOD
    PROGRAMS COMING SOON: Greedy Bucks :: Vengeance Cash
    NOW OFFERING OVER 60 SITES
    CONTACT :: JAMES SMITH :: CHIEF TECHNOLOGY OFFICER :: ICQ (711385133)
  • com
    Confirmed User
    • Aug 2003
    • 4541

    #2
    Go to google and lookup the Tao of Regular Expressions, or go buy Mastering Regular Expressions... or steal it.

    Real. Professional. Hosting.
    .:Expect Nothing Less:.
    320-078-843 :: www.realprohosting.com :: [email protected]

    Comment

    • jwerd
      Confirmed User
      • Jun 2003
      • 1953

      #3
      Well, I'd do this a little differently:

      <?php
      //Something.txt will contain something needed in the search//

      $fp = @fopen("something.txt", "r");
      while($buffer = fread($fp, 1024))
      {
      if(strstr($buffer, "something"))
      {
      echo " I found something, $buffer! ";
      } else {
      die()
      }

      again, I am kind of tired so I am not sure if this will work because I haven't tested it - have no way of testing it - and again, I am sleepy... but if that is something that will help you, USE IT!

      Peace
      Yii Framework Guru - Seasoned PHP vet - Partner @ XXXCoupon.com

      Comment

      • Jimbo
        Confirmed User
        • Oct 2001
        • 3989

        #4
        "/href=[\"' ]?([^\"' >]+)[\"' ]?[^>]*>/i"

        try this
        free sex videos

        Comment

        • JDog
          Confirmed User
          • Feb 2003
          • 7453

          #5
          Originally posted by Jimbo
          "/href=[\"' ]?([^\"' >]+)[\"' ]?[^>]*>/i"

          try this
          thanx man!
          worked fucking great!

          jDoG
          NSCash now powering ReelProfits.com
          ALSO FEATURING: NSCash.com :: SoloDollars.com :: ReelProfits.com :: BiminiBucks.com :: VOD
          PROGRAMS COMING SOON: Greedy Bucks :: Vengeance Cash
          NOW OFFERING OVER 60 SITES
          CONTACT :: JAMES SMITH :: CHIEF TECHNOLOGY OFFICER :: ICQ (711385133)

          Comment

          Working...