Closed Thread
Results 1 to 7 of 7

Thread: Regex and preg match?

  1. #1
    phpforfun's Avatar
    phpforfun is offline Speaks fluent binary
    Join Date
    Feb 2008
    Posts
    1,232
    Blog Entries
    17
    Rep Power
    24

    Regex and preg match?

    I am trying to get the content of a text area of a page... when I return the result, it returns an empty array, which is odd, because the code seems to work fine when I test it with other pages.
    My PregMatch
    Code:
    preg_match('#<textarea wrap="off" nowrap name="errlog" id="errtext" class="output" cols="80" rows="25" readonly>(.*?)</textarea>#'$page$array); 
    Code on page
    Code:
        <div align="center">
            <
    textarea wrap="off" nowrap name="errlog" id="errtext" class="output" cols="80" rows="25" readonly>[Sat May 30 13:19:55 2009] [error] [client 67.101.88.149File does not exist: /home/blogforf/public_html/cPanel_magic_revision_1187247941
    [Sat May 30 13:19:52 2009] [error] [client 67.101.88.149File does not exist: /home/blogforf/public_html/cPanel_magic_revision_87687266601.2207refererhttp://blogforfree.net/geterror.php
    [Sat May 30 13:19:52 2009] [error] [client 67.101.88.149File does not exist: /home/blogforf/public_html/cPanel_magic_revision_1229605105refererhttp://blogforfree.net/geterror.php
    [Sat May 30 13:19:52 2009] [error] [client 67.101.88.149File does not exist: /home/blogforf/public_html/cPanel_magic_revision_9361523513.50525refererhttp://blogforfree.net/geterror.php
    [Sat May 30 13:19:52 2009] [error] [client 67.101.88.149File does not exist: /home/blogforf/public_html/cPanel_magic_revision_1238671112refererhttp://blogforfree.net/geterror.php
    [Sat May 30 13:19:52 2009] [error] [client 67.101.88.149File does not exist: /home/blogforf/public_html/cPanel_magic_revision_1231999238refererhttp://blogforfree.net/geterror.php
    [Sat May 30 13:19:52 2009] [error] [client 67.101.88.149File does not exist: /home/blogforf/public_html/cPanel_magic_revision_73970499338.6905refererhttp://blogforfree.net/geterror.php
    [Sat May 30 13:19:52 2009] [error] [client 67.101.88.149File does not exist: /home/blogforf/public_html/cPanel_magic_revision_1187247945refererhttp://blogforfree.net/geterror.php
    [Sat May 30 13:19:52 2009] [error] [client 67.101.88.149File does not exist: /home/blogforf/public_html/cPanel_magic_revision_90618918027.6706refererhttp://blogforfree.net/geterror.php
    [Sat May 30 13:19:52 2009] [error] [client 67.101.88.149File does not exist: /home/blogforf/public_html/cPanel_magic_revision_53782990950.6602refererhttp://blogforfree.net/geterror.php
    [Sat May 30 13:19:52 2009] [error] [client 67.101.88.149File does not exist: /home/blogforf/public_html/cPanel_magic_revision_1238671078refererhttp://blogforfree.net/geterror.php
    [Sat May 30 13:19:52 2009] [error] [client 67.101.88.149File does not exist: /home/blogforf/public_html/cPanel_magic_revision_1187247941
    [Sat May 30 13:03:05 2009] [error] [client 67.101.88.149File does not exist: /home/blogforf/public_html/favicon.ico
    [Sat May 30 13:03:02 2009] [error] [client 67.101.88.149File does not exist: /home/blogforf/public_html/favicon.ico
    [Sat May 30 11:59:00 2009] [error] [client 70.176.218.8File does not exist: /home/blogforf/public_html/testasdf
    [Sat May 30 11:58:56 2009] [error] [client 70.176.218.8File does not exist: /home/blogforf/public_html/test
    [Sat May 30 11:51:16 2009] [error] [client 70.176.218.8File does not exist: /home/blogforf/public_html/pages/members/awstats_imagesrefererhttp://blogforfree.net/pages/members/awstats.php
    [Sat May 30 11:51:15 2009] [error] [client 70.176.218.8File does not exist: /home/blogforf/public_html/pages/members/awstats_imagesrefererhttp://blogforfree.net/pages/members/awstats.php
    [Sat May 30 11:51:15 2009] [error] [client 70.176.218.8File does not exist: /home/blogforf/public_html/pages/members/awstats_imagesrefererhttp://blogforfree.net/pages/members/awstats.php
    [Sat May 30 11:51:15 2009] [error] [client 70.176.218.8File does not exist: /home/blogforf/public_html/pages/members/awstats_imagesrefererhttp://blogforfree.net/pages/members/awstats.php
    [Sat May 30 11:51:15 2009] [error] [client 70.176.218.8File does not exist: /home/blogforf/public_html/pages/members/awstats_imagesrefererhttp://blogforfree.net/pages/members/awstats.php
    [Sat May 30 11:51:15 2009] [error] [client 70.176.218.8File does not exist: /home/blogforf/public_html/pages/members/awstats_imagesrefererhttp://blogforfree.net/pages/members/awstats.php
    [Sat May 30 11:51:15 2009] [error] [client 70.176.218.8File does not exist: /home/blogforf/public_html/pages/members/awstats_imagesrefererhttp://blogforfree.net/pages/members/awstats.php
    [Sat May 30 11:51:15 2009] [error] [client 70.176.218.8File does not exist: /home/blogforf/public_html/pages/members/awstats_imagesrefererhttp://blogforfree.net/pages/members/awstats.php
    [Sat May 30 11:51:15 2009] [error] [client 70.176.218.8File does not exist: /home/blogforf/public_html/pages/members/awstats_imagesrefererhttp://blogforfree.net/pages/members/awstats.php
    [Sat May 30 11:51:15 2009] [error] [client 70.176.218.8File does not exist: /home/blogforf/public_html/pages/members/awstats_imagesrefererhttp://blogforfree.net/pages/members/awstats.php
    [Sat May 30 11:51:15 2009] [error] [client 70.176.218.8File does not exist: /home/blogforf/public_html/pages/members/awstats_imagesrefererhttp://blogforfree.net/pages/members/awstats.php
    [Sat May 30 11:51:15 2009] [error] [client 70.176.218.8File does not exist: /home/blogforf/public_html/pages/members/awstats_imagesrefererhttp://blogforfree.net/pages/members/awstats.php
    [Sat May 30 11:51:15 2009] [error] [client 70.176.218.8File does not exist: /home/blogforf/public_html/pages/members/awstats_imagesrefererhttp://blogforfree.net/pages/members/awstats.php
    [Sat May 30 11:51:15 2009] [error] [client 70.176.218.8File does not exist: /home/blogforf/public_html/pages/members/awstats_imagesrefererhttp://blogforfree.net/pages/members/awstats.php
    [Sat May 30 11:51:15 2009] [error] [client 70.176.218.8File does not exist: /home/blogforf/public_html/pages/members/awstats_imagesrefererhttp://blogforfree.net/pages/members/awstats.php
    [Sat May 30 11:51:15 2009] [error] [client 70.176.218.8File does not exist: /home/blogforf/public_html/pages/members/awstats_imagesrefererhttp://blogforfree.net/pages/members/awstats.php
    [Sat May 30 11:51:15 2009] [error] [client 70.176.218.8File does not exist: /home/blogforf/public_html/pages/members/awstats_imagesrefererhttp://blogforfree.net/pages/members/awstats.php</textarea>
        
    </div>
    </
    div
    I dont know if it matters or not, but the content of the textarea on the REAL page is actually 300 lines long, I shortened the error logs above..

    Any idea why it wouldnt work?
    Checkout my new forum! http://adminreference.com/

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    phpforfun's Avatar
    phpforfun is offline Speaks fluent binary
    Join Date
    Feb 2008
    Posts
    1,232
    Blog Entries
    17
    Rep Power
    24

    Re: Apply for a great card today

    Quote Originally Posted by MSliveFormNew View Post
    Hi there!
    Compare and apply now for a balance transfer credit card!
    Transfer your high balances now!
    1stcreditcardsoffer eu]Apply Credit Card Transfer No Annual Fee
    Have a nice day!
    BB!




    P S if you don't want to see this message please write us to no ads08@gmail com with subject "NO ADS" and URL of your forum!
    Your URL will be immediately removed from the advertising list!
    Thank you for cooperation!
    ****it, no one ever replies to me on here, Now only bots reply, thats like.. going backwards.
    Checkout my new forum! http://adminreference.com/

  4. #3
    Jordan Guest

    Re: Regex and preg match?

    I didn't have an answer for you, that is why I didn't reply. Orjan and John have a better grasp of regular expressions than I do. Are you sure that $page has data?

  5. #4
    Join Date
    Jul 2006
    Location
    Amherst, New York, United States
    Posts
    6,277
    Blog Entries
    26
    Rep Power
    20

    Re: Regex and preg match?

    If you can explain to me what .*? means, I will give you a solution. I'm only asking because it doesn't make sense to me.

  6. #5
    phpforfun's Avatar
    phpforfun is offline Speaks fluent binary
    Join Date
    Feb 2008
    Posts
    1,232
    Blog Entries
    17
    Rep Power
    24

    Re: Regex and preg match?

    It catches anything, but its already fixed... Line below works
    Code:
     preg_match('#<textarea wrap="off" nowrap name="errlog" id="errtext" class="output" cols="80" rows="25" readonly>(.*?)</textarea>#is'$page$array); 
    Checkout my new forum! http://adminreference.com/

  7. #6
    Jordan Guest

    Re: Regex and preg match?

    How did you come about adding is?

  8. #7
    Join Date
    Jul 2006
    Location
    Amherst, New York, United States
    Posts
    6,277
    Blog Entries
    26
    Rep Power
    20

    Re: Regex and preg match?

    Actually the .* (dot-star) matches anything, The question mark makes the dot-star reluctant. If you were to use /o+/ in "Jooohn" you would match a single group of three o's. However, if you were to use /o+?/ you will get the same result, but you will match three individual o's rather than one group of three o's.

    Here is a regular expression to match content between a pair of tags based on the elements id ($id).

    Code:
    #<([a-z]+)[^<>]*id=\"$id\"[^>]*>(.*)</\\1>#is

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Chess match
    By asafe in forum ASCII Chess
    Replies: 6
    Last Post: 06-18-2011, 02:44 PM
  2. No match for operator=
    By matio in forum C and C++
    Replies: 2
    Last Post: 07-21-2010, 12:15 PM
  3. preg match getting me down!
    By adzeds in forum PHP Development
    Replies: 0
    Last Post: 03-02-2010, 01:11 AM
  4. Anyone up for a friendly match?
    By Parabola in forum ASCII Chess
    Replies: 25
    Last Post: 08-27-2009, 03:05 PM
  5. MySQL: MATCH AGAINST and LIKE
    By BASHERS33 in forum Database & Database Programming
    Replies: 3
    Last Post: 08-13-2009, 03:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts