easy regex question: stops on some white space?
Eric C
eric-yrHdaQSNc4gdnm+yROfE0A at public.gmane.org
Mon Jun 11 11:58:13 EDT 2007
[quote]
Wouldn't s/infod6/ /g in perl solve the problem?
just replace the whitespace ( / / ) with whatever you
want, but since
you want it gone, that'd be
your best bet. The g is for global, supposing infod6
shows up again.
You can just omit the stuff before infod6 by hand if
you want, or you
can run it thru:
s/[\d\D]*infod6/ /
Again, just remove the whitespace in / / to make it
//. (No
whitespace).
I'm assuming you're using perl or cgi.
Hope this helps.
--
Samuel (shardz)
[/quote]
hi,
this is probably an example of not forming my question
clearly. what i'm trying to do is extract part of a
bittorrent metadata file. i want to start the
extraction from "info" and i want it to end at the end
of the document. not at the end of a line. i'm
trying to do this in php. here's an example:
[test torrent]
d8:announce44:http://tpb.tracker.thepiratebay.org/announce18:azureus_propertiesd17:dht_backup_enablei1ee7:comment25:Cory
Doctorow 2006 RedHat13:comment.utf-825:Cory Doctorow
2006 RedHat10:created by15:Azureus/2.5.0.413:creation
datei1180190631e8:encoding5:UTF-84:infod6:lengthi99391572e4:name19:060506-doctorow.ogg10:name.utf-819:060506-doctorow.ogg12:piece
lengthi65536e6:pieces30340:some_random stuff here
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
and now for a couple returns:
and another WITH TAB and
xxx...
END.
[/test torrent]
so i'm trying to write a script that will give me
everything from "info" all the way to "END." when i
use something like:
preg_match("/info.*/", $var1, $var2);
unfortunately this stops at "and now for a couple
returns:" and not at "END." i've tried several
modifiers such as /m and /s but no luck.
it seems a monkey banging on a keyboard for a couple
of days will not produce the proper regular expression
to solve my problem.
- eric the monkey.
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
More information about the Discuss
mailing list