Jump to content

Regex and preg match?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
6 replies to this topic

#1
phpforfun

phpforfun

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,236 posts
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
preg_match('#<textarea wrap="off" nowrap name="errlog" id="errtext" class="output" cols="80" rows="25" readonly>(.*?)</textarea>#', $page, $array);

Code on page
	<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.149] File does not exist: /home/blogforf/public_html/cPanel_magic_revision_1187247941

[Sat May 30 13:19:52 2009] [error] [client 67.101.88.149] File does not exist: /home/blogforf/public_html/cPanel_magic_revision_87687266601.2207, referer: http://blogforfree.net/geterror.php

[Sat May 30 13:19:52 2009] [error] [client 67.101.88.149] File does not exist: /home/blogforf/public_html/cPanel_magic_revision_1229605105, referer: http://blogforfree.net/geterror.php

[Sat May 30 13:19:52 2009] [error] [client 67.101.88.149] File does not exist: /home/blogforf/public_html/cPanel_magic_revision_9361523513.50525, referer: http://blogforfree.net/geterror.php

[Sat May 30 13:19:52 2009] [error] [client 67.101.88.149] File does not exist: /home/blogforf/public_html/cPanel_magic_revision_1238671112, referer: http://blogforfree.net/geterror.php

[Sat May 30 13:19:52 2009] [error] [client 67.101.88.149] File does not exist: /home/blogforf/public_html/cPanel_magic_revision_1231999238, referer: http://blogforfree.net/geterror.php

[Sat May 30 13:19:52 2009] [error] [client 67.101.88.149] File does not exist: /home/blogforf/public_html/cPanel_magic_revision_73970499338.6905, referer: http://blogforfree.net/geterror.php

[Sat May 30 13:19:52 2009] [error] [client 67.101.88.149] File does not exist: /home/blogforf/public_html/cPanel_magic_revision_1187247945, referer: http://blogforfree.net/geterror.php

[Sat May 30 13:19:52 2009] [error] [client 67.101.88.149] File does not exist: /home/blogforf/public_html/cPanel_magic_revision_90618918027.6706, referer: http://blogforfree.net/geterror.php

[Sat May 30 13:19:52 2009] [error] [client 67.101.88.149] File does not exist: /home/blogforf/public_html/cPanel_magic_revision_53782990950.6602, referer: http://blogforfree.net/geterror.php

[Sat May 30 13:19:52 2009] [error] [client 67.101.88.149] File does not exist: /home/blogforf/public_html/cPanel_magic_revision_1238671078, referer: http://blogforfree.net/geterror.php

[Sat May 30 13:19:52 2009] [error] [client 67.101.88.149] File does not exist: /home/blogforf/public_html/cPanel_magic_revision_1187247941

[Sat May 30 13:03:05 2009] [error] [client 67.101.88.149] File does not exist: /home/blogforf/public_html/favicon.ico

[Sat May 30 13:03:02 2009] [error] [client 67.101.88.149] File does not exist: /home/blogforf/public_html/favicon.ico

[Sat May 30 11:59:00 2009] [error] [client 70.176.218.8] File does not exist: /home/blogforf/public_html/testasdf

[Sat May 30 11:58:56 2009] [error] [client 70.176.218.8] File does not exist: /home/blogforf/public_html/test

[Sat May 30 11:51:16 2009] [error] [client 70.176.218.8] File does not exist: /home/blogforf/public_html/pages/members/awstats_images, referer: http://blogforfree.n...ers/awstats.php

[Sat May 30 11:51:15 2009] [error] [client 70.176.218.8] File does not exist: /home/blogforf/public_html/pages/members/awstats_images, referer: http://blogforfree.n...ers/awstats.php

[Sat May 30 11:51:15 2009] [error] [client 70.176.218.8] File does not exist: /home/blogforf/public_html/pages/members/awstats_images, referer: http://blogforfree.n...ers/awstats.php

[Sat May 30 11:51:15 2009] [error] [client 70.176.218.8] File does not exist: /home/blogforf/public_html/pages/members/awstats_images, referer: http://blogforfree.n...ers/awstats.php

[Sat May 30 11:51:15 2009] [error] [client 70.176.218.8] File does not exist: /home/blogforf/public_html/pages/members/awstats_images, referer: http://blogforfree.n...ers/awstats.php

[Sat May 30 11:51:15 2009] [error] [client 70.176.218.8] File does not exist: /home/blogforf/public_html/pages/members/awstats_images, referer: http://blogforfree.n...ers/awstats.php

[Sat May 30 11:51:15 2009] [error] [client 70.176.218.8] File does not exist: /home/blogforf/public_html/pages/members/awstats_images, referer: http://blogforfree.n...ers/awstats.php

[Sat May 30 11:51:15 2009] [error] [client 70.176.218.8] File does not exist: /home/blogforf/public_html/pages/members/awstats_images, referer: http://blogforfree.n...ers/awstats.php

[Sat May 30 11:51:15 2009] [error] [client 70.176.218.8] File does not exist: /home/blogforf/public_html/pages/members/awstats_images, referer: http://blogforfree.n...ers/awstats.php

[Sat May 30 11:51:15 2009] [error] [client 70.176.218.8] File does not exist: /home/blogforf/public_html/pages/members/awstats_images, referer: http://blogforfree.n...ers/awstats.php

[Sat May 30 11:51:15 2009] [error] [client 70.176.218.8] File does not exist: /home/blogforf/public_html/pages/members/awstats_images, referer: http://blogforfree.n...ers/awstats.php

[Sat May 30 11:51:15 2009] [error] [client 70.176.218.8] File does not exist: /home/blogforf/public_html/pages/members/awstats_images, referer: http://blogforfree.n...ers/awstats.php

[Sat May 30 11:51:15 2009] [error] [client 70.176.218.8] File does not exist: /home/blogforf/public_html/pages/members/awstats_images, referer: http://blogforfree.n...ers/awstats.php

[Sat May 30 11:51:15 2009] [error] [client 70.176.218.8] File does not exist: /home/blogforf/public_html/pages/members/awstats_images, referer: http://blogforfree.n...ers/awstats.php

[Sat May 30 11:51:15 2009] [error] [client 70.176.218.8] File does not exist: /home/blogforf/public_html/pages/members/awstats_images, referer: http://blogforfree.n...ers/awstats.php

[Sat May 30 11:51:15 2009] [error] [client 70.176.218.8] File does not exist: /home/blogforf/public_html/pages/members/awstats_images, referer: http://blogforfree.n...ers/awstats.php

[Sat May 30 11:51:15 2009] [error] [client 70.176.218.8] File does not exist: /home/blogforf/public_html/pages/members/awstats_images, referer: http://blogforfree.n....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
phpforfun

phpforfun

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,236 posts

MSliveFormNew said:

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/

#3
Guest_Jordan_*

Guest_Jordan_*
  • Guests
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?

#4
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
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.

#5
phpforfun

phpforfun

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,236 posts
It catches anything, but its already fixed... Line below works
 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/

#6
Guest_Jordan_*

Guest_Jordan_*
  • Guests
How did you come about adding is?

#7
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
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).

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