homepage Welcome to WebmasterWorld Guest from 54.166.100.8
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Trying to match a string with line-breaks
And also getting the information between the ends, not including.
otem




msg:3349352
 3:18 am on May 25, 2007 (gmt 0)

I'm trying to use PHP match some strings of code in a document.

The document has multiple lines, with a typical section of code looking like this:

(...)csv.zip

UEsDBBQACAAIAJIIuDYfwAAAAAAAAAAASAAAAQWRTZW5zZS1SZXBvcnQuY3N2c0ksSdUJSExP
VcjMLShK7r1nHOyUzOLoaIO4cEasQRipzgG+Oq6JfmZeenFXEYGBua6Bqa6RiY6FjpGOkam
egYGqjomekamfOgZ6BRsZcIfkFasd2OUcy1KLgCZHUgYgBQSwcIFDs3h2UAAACJAAAAUEsBAhQA
FAAIAAgAkgi4asNhQ7N4dlAAAAiQAAABIAAAAfsfAAAAAAAAAAAAAEFkU2Vuc2UtUmVwb3J0LmNz
dlBLBQYAAAAAAQAAAAClAAAAAAA=
------=_Part_77(...)

Right now I'm using the following line of code to try to match everything after the "csv.zip" and the line break and upto "------":

preg_match_all("/\csv.zip\n(.*¦\n*)------/",$data,$out);

My major problem is that its not catching anything. I think this might have to do with the line breaks. My understanding is .* will match upto zero-plus characters of anything except for line breaks, so thats why I said that or upto zero-plus line breaks. Should that part of the code be different?

The other issue I'm having is that I think this will includ the starting and ending lines of the match. How might I code this so that it includes everything inbetween except for the end pieces?

Thanks.

 

ogletree




msg:3349385
 4:33 am on May 25, 2007 (gmt 0)

Let me know if you get the answer.

coopster




msg:3353727
 6:00 pm on May 30, 2007 (gmt 0)

I would match up anything that is not a space character in the beginning of the pattern after the filename then use parentheses around the subpattern that you want to capture. The "matches" argument will be an array of the matched subpatterns. You can view them by printing out the array after you run the regular expression.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved