473,503 Members | 1,639 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parsing txt file

Hello, I was wondering if anyone could show me the easiest way to parse
an txt file for proxies, I was thinking of using regex, however I am
unsure about how to carry out the actual "parsing".

Any and all help would be greatly appreciated, thankyou

Jul 30 '06 #1
5 1583
I forgot to mention the proxies would be in the ipaddress:port format

The.Relina...@gmail.com wrote:
Hello, I was wondering if anyone could show me the easiest way to parse
an txt file for proxies, I was thinking of using regex, however I am
unsure about how to carry out the actual "parsing".

Any and all help would be greatly appreciated, thankyou
Jul 30 '06 #2
Th***********@gmail.com wrote:
Hello, I was wondering if anyone could show me the easiest way to parse
an txt file for proxies, I was thinking of using regex, however I am
unsure about how to carry out the actual "parsing".
How about if you show two or three lines of the file you are trying to
parse, along with an explanation of what values you hope to get from it?

miguel
--
Photos from 40 countries on 5 continents: http://travel.u.nu
Latest photos: Malaysia; Thailand; Singapore; Spain; Morocco
Airports of the world: http://airport.u.nu
Jul 30 '06 #3
the file would be an html file such as the one below,and I hope to get
the 23.324.4.034:344, 35.622.66.34:8080 from it

<html>
<head>
<titleTest </title>
</head>
<body>
random text 23.324.4.034:344
random text random text
35.622.66.34:8080 random text
</body>
</html>
Miguel Cruz wrote:
Th***********@gmail.com wrote:
Hello, I was wondering if anyone could show me the easiest way to parse
an txt file for proxies, I was thinking of using regex, however I am
unsure about how to carry out the actual "parsing".

How about if you show two or three lines of the file you are trying to
parse, along with an explanation of what values you hope to get from it?

miguel
--
Photos from 40 countries on 5 continents: http://travel.u.nu
Latest photos: Malaysia; Thailand; Singapore; Spain; Morocco
Airports of the world: http://airport.u.nu
Jul 30 '06 #4
Rik
Th***********@gmail.com wrote:
the file would be an html file such as the one below,and I hope to get
the 23.324.4.034:344, 35.622.66.34:8080 from it

<html>
<head>
<titleTest </title>
</head>
<body>
random text 23.324.4.034:344
random text random text
35.622.66.34:8080 random text
</body>
</html>

Somewhat crude, but I think thiw sill suffice:

preg_match_all('/[0-9]{1,3}(?:\.[0-9]{1,3}){3}:[0-9]+/',$html,$matches);

If you want to validate the IP adresses & portnumbers it's a whole other
game.

Grtz,
--
Rik Wasmus
Jul 30 '06 #5
Thankyou Rik, you solved the problem, and no I do not need to validate
anything, thankyou both for your help
Rik wrote:
Th***********@gmail.com wrote:
the file would be an html file such as the one below,and I hope to get
the 23.324.4.034:344, 35.622.66.34:8080 from it

<html>
<head>
<titleTest </title>
</head>
<body>
random text 23.324.4.034:344
random text random text
35.622.66.34:8080 random text
</body>
</html>


Somewhat crude, but I think thiw sill suffice:

preg_match_all('/[0-9]{1,3}(?:\.[0-9]{1,3}){3}:[0-9]+/',$html,$matches);

If you want to validate the IP adresses & portnumbers it's a whole other
game.

Grtz,
--
Rik Wasmus
Jul 30 '06 #6

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

Similar topics

3
3637
by: Willem Ligtenberg | last post by:
I decided to use SAX to parse my xml file. But the parser crashes on: File "/usr/lib/python2.3/site-packages/_xmlplus/sax/handler.py", line 38, in fatalError raise exception...
2
3916
by: Cigdem | last post by:
Hello, I am trying to parse the XML files that the user selects(XML files are on anoher OS400 system called "wkdis3"). But i am permenantly getting that error: Directory0: \\wkdis3\ROOT\home...
3
3485
by: Pir8 | last post by:
I have a complex xml file, which contains stories within a magazine. The structure of the xml file is as follows: <?xml version="1.0" encoding="ISO-8859-1" ?> <magazine> <story>...
1
2440
by: Christoph Bisping | last post by:
Hello! Maybe someone is able to give me a little hint on this: I've written a vb.net app which is mainly an interpreter for specialized CAD/CAM files. These files mainly contain simple movement...
4
4843
by: Rick Walsh | last post by:
I have an HTML table in the following format: <table> <tr><td>Header 1</td><td>Header 2</td></tr> <tr><td>1</td><td>2</td></tr> <tr><td>3</td><td>4</td></tr> <tr><td>5</td><td>6</td></tr>...
3
4359
by: toton | last post by:
Hi, I have some ascii files, which are having some formatted text. I want to read some section only from the total file. For that what I am doing is indexing the sections (denoted by .START in...
9
1967
by: Paulers | last post by:
Hello, I have a log file that contains many multi-line messages. What is the best approach to take for extracting data out of each message and populating object properties to be stored in an...
13
4474
by: Chris Carlen | last post by:
Hi: Having completed enough serial driver code for a TMS320F2812 microcontroller to talk to a terminal, I am now trying different approaches to command interpretation. I have a very simple...
13
2785
by: charliefortune | last post by:
I am fetching some product feeds with PHP like this $merch = substr($key,1); $feed = file_get_contents($_POST); $fp = fopen("./feeds/feed".$merch.".txt","w+"); fwrite ($fp,$feed); fclose...
2
3595
by: Felipe De Bene | last post by:
I'm having problems parsing an HTML file with the following syntax : <TABLE cellspacing=0 cellpadding=0 ALIGN=CENTER BORDER=1 width='100%'> <TH BGCOLOR='#c0c0c0' Width='3%'>User ID</TH> <TH...
0
7278
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7458
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
5578
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,...
0
4672
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
3167
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
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
736
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.