Rowsdower!
01-22-2010, 04:00 PM
I've never written a successful regex in my life and I'm starting to tinker with them now. I have a text file, the contents of which I am loading into a variable. The basic text file looks like a lot of lines like this:
"PRBUPort"="80"
"PRBUPath"="/"
"PRBUUrl"="http://mysite.com/"
I then want to run through the variable and pull out all instances of "PRBUUrl"="<some url here>" so that I can capture all URLs passed in the text file for this particular recurring variable.
I'm using this preg_match_all to capture each instance:
preg_match_all('%"PRBUUrl"=".*"%',$text_1,$url_list_1);
That's working well enough, but I'd really like to actually exclude the "PRBUUrl"=" and " parts so that I get ONLY the part in the middle. The URL is not always an actual URL - it can have wildcard characters (*), IP addresses, etc. and other URLs actually appear in other places that I DON'T want to capture (so I can't just capture all URLs, for example).
This is supposed to be pretty easy stuff but it's just not clicking for me... Any ideas?
"PRBUPort"="80"
"PRBUPath"="/"
"PRBUUrl"="http://mysite.com/"
I then want to run through the variable and pull out all instances of "PRBUUrl"="<some url here>" so that I can capture all URLs passed in the text file for this particular recurring variable.
I'm using this preg_match_all to capture each instance:
preg_match_all('%"PRBUUrl"=".*"%',$text_1,$url_list_1);
That's working well enough, but I'd really like to actually exclude the "PRBUUrl"=" and " parts so that I get ONLY the part in the middle. The URL is not always an actual URL - it can have wildcard characters (*), IP addresses, etc. and other URLs actually appear in other places that I DON'T want to capture (so I can't just capture all URLs, for example).
This is supposed to be pretty easy stuff but it's just not clicking for me... Any ideas?