473,507 Members | 2,375 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

finding a specific area from page using regular expression

hi friends,
i have a bunch of html pages and i want to fetch records from them and
i m really confused how i can do after working with regular
expressions and other stuffs from last few days can anyone help me
with this ?

i have a pages with html and table all scatter there..now i want just
specific table from the page and all records in that page, i was
successfull somehow but still have problems ,here are they..

my example page...(just a table it has all the tags like html but i
didnt write here just the thing i want is here)

<table>
<tr>
<img src=..">
</tr>
<tr>
<table>
<tr>
<tr>
<td>
<b>name1</B>
<br>
<font size=2 color=darkgray ><i>address1</i></font><br>
<br>phone no
| <a href=mailto:ma**@gmail.com>E-mail1 </a>
| <a href='www.website.com' target=_blank>website1</a>
</font>
</td>
</tr>
</tr>
<tr>
<bname2</b>
.........
</tr>
</table>
</tr>
</table>

now from that table i want name,address,phone no,email,website..
using preg_replace function i was able to find all those things but it
removes <Atag so email and website are also removed...can anyone
tell me how i can find email and website first from that code and then
using preg_replace i can get other records...or else can anyone tell
me any better solution like currently by using while loop and using if
condition i m breaking at the main table and then fetching each record
but any better solution ?

Aug 4 '07 #1
4 1630
Hardik Dangar wrote:
hi friends,
i have a bunch of html pages and i want to fetch records from them and
i m really confused how i can do after working with regular
expressions and other stuffs from last few days can anyone help me
with this ?

i have a pages with html and table all scatter there..now i want just
specific table from the page and all records in that page, i was
successfull somehow but still have problems ,here are they..

my example page...(just a table it has all the tags like html but i
didnt write here just the thing i want is here)

<table>
<tr>
<img src=..">
</tr>
<tr>
<table>
<tr>
<tr>
<td>
<b>name1</B>
<br>
<font size=2 color=darkgray ><i>address1</i></font><br>
<br>phone no
><a href=mailto:ma**@gmail.com>E-mail1 </a>
<a href='www.website.com' target=_blank>website1</a>
</font>
</td>
</tr>
</tr>
<tr>
<bname2</b>
.........
</tr>
</table>
</tr>
</table>

now from that table i want name,address,phone no,email,website..
using preg_replace function i was able to find all those things but it
removes <Atag so email and website are also removed...can anyone
tell me how i can find email and website first from that code and then
using preg_replace i can get other records...or else can anyone tell
me any better solution like currently by using while loop and using if
condition i m breaking at the main table and then fetching each record
but any better solution ?
Check out the DOM functions:
http://uk.php.net/manual/en/ref.dom.php
Aug 4 '07 #2
On Aug 4, 10:26 pm, "Paul Lautman" <paul.laut...@btinternet.com>
wrote:
Hardik Dangar wrote:
hi friends,
i have a bunch of html pages and i want to fetch records from them and
i m really confused how i can do after working with regular
expressions and other stuffs from last few days can anyone help me
with this ?
i have a pages with html and table all scatter there..now i want just
specific table from the page and all records in that page, i was
successfull somehow but still have problems ,here are they..
my example page...(just a table it has all the tags like html but i
didnt write here just the thing i want is here)
<table>
<tr>
<img src=..">
</tr>
<tr>
<table>
<tr>
<tr>
<td>
<b>name1</B>
<br>
<font size=2 color=darkgray ><i>address1</i></font><br>
<br>phone no
<a href=mailto:m...@gmail.com>E-mail1 </a>
<a href='www.website.com'target=_blank>website1</a>
</font>
</td>
</tr>
</tr>
<tr>
<bname2</b>
.........
</tr>
</table>
</tr>
</table>
now from that table i want name,address,phone no,email,website..
using preg_replace function i was able to find all those things but it
removes <Atag so email and website are also removed...can anyone
tell me how i can find email and website first from that code and then
using preg_replace i can get other records...or else can anyone tell
me any better solution like currently by using while loop and using if
condition i m breaking at the main table and then fetching each record
but any better solution ?

Check out the DOM functions:http://uk.php.net/manual/en/ref.dom.php
@paul
thanx for the help but,
can you explain me how i can use it ?
i didnt get i guess its for working with xml
how can i use with my problem ?

Aug 4 '07 #3
Hardik Dangar wrote:
On Aug 4, 10:26 pm, "Paul Lautman" <paul.laut...@btinternet.com>
wrote:
>Hardik Dangar wrote:
>>hi friends,
i have a bunch of html pages and i want to fetch records from them
and i m really confused how i can do after working with regular
expressions and other stuffs from last few days can anyone help me
with this ?
>>i have a pages with html and table all scatter there..now i want
just specific table from the page and all records in that page, i
was successfull somehow but still have problems ,here are they..
>>my example page...(just a table it has all the tags like html but i
didnt write here just the thing i want is here)
>><table>
<tr>
<img src=..">
</tr>
<tr>
<table>
<tr>
<tr>
<td>
<b>name1</B>
<br>
<font size=2 color=darkgray ><i>address1</i></font><br>
<br>phone no
<a href=mailto:m...@gmail.com>E-mail1 </a>
<a href='www.website.com'target=_blank>website1</a>
</font>
</td>
</tr>
</tr>
<tr>
<bname2</b>
.........
</tr>
</table>
</tr>
</table>
>>now from that table i want name,address,phone no,email,website..
using preg_replace function i was able to find all those things but
it removes <Atag so email and website are also removed...can
anyone tell me how i can find email and website first from that
code and then using preg_replace i can get other records...or else
can anyone tell me any better solution like currently by using
while loop and using if condition i m breaking at the main table
and then fetching each record but any better solution ?

Check out the DOM functions:http://uk.php.net/manual/en/ref.dom.php

@paul
thanx for the help but,
can you explain me how i can use it ?
i didnt get i guess its for working with xml
how can i use with my problem ?
As long as your HTML is "well formed", you can use the DOM functions to
process it.
Aug 4 '07 #4
On Aug 4, 12:23 pm, Hardik Dangar <hardikdan...@gmail.comwrote:
[snip]
>
now from that table i want name,address,phone no,email,website..
using preg_replace function i was able to find all those things but it
removes <Atag so email and website are also removed...can anyone
tell me how i can find email and website first from that code and then
using preg_replace i can get other records...or else can anyone tell
me any better solution like currently by using while loop and using if
condition i m breaking at the main table and then fetching each record
but any better solution ?
This should do what you want (retrieving the email and URL):

$matches = array();

preg_match('/<a href=[\'"]?mailto:([^>\'"\s]+).*<a href=[\'"]?([^>
\'"\s]+)/s',$yourPageContents,$matches);

print "email: $matches[1], url: $matches[2]";

HTH
-Kurt

Aug 6 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
6968
by: Eric Linders | last post by:
Hi, I'm trying to figure out the most efficient method for taking the first character in a string (which will be a number), and use it as a variable to check to see if the other numbers in the...
5
2501
by: lawrence | last post by:
"Garp" <garp7@no7.blueyonder.co.uk> wrote in message news:<_vpuc.1424$j_3.13346038@news-text.cableinet.net>... > "lawrence" <lkrubner@geocities.com> wrote in message >...
7
50871
by: Doug van Vianen | last post by:
I recently found the following JavaScript code which is supposed to let one find then use the ip address of the person accessing the web page containing the script. <SCRIPT...
3
1555
by: greenflame | last post by:
I am trying to find a regular expression that returns true in the following cases but no others. 2.0 2.4 2. 324.0e345 234e34 34.e-43 234.673
5
1640
by: Terry Olsen | last post by:
Is there a good way to find a pattern of bytes/chars in a stream? I've got a serial port connected to a tcp port. I need to be able to catch a unique character string in the stream so that I can...
2
1815
by: Lad | last post by:
Did anyone try to find out a regular expression for finding an email address in a text? Thank you for the reply L.
2
2320
by: jd | last post by:
hi all, i'm using regular expression to find the url of the page to be opened using the window.open(). typical urls look like this http://domain.com/path-to-page.html right now i'm trying...
6
1693
by: Jack | last post by:
Hi there, Given a standard .NET string, does anyone know what the regular expression would be to locate each (optional) formatting item in the string (or more likely does anyone have a link that...
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7485
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5042
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
760
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.