By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,614 Members | 1,680 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,614 IT Pros & Developers. It's quick & easy.

Attempting* to use reg exp. Guidance needed O:)

Expert 5K+
P: 6,050
So, i'm making a proxy, cos, well, i'm bored. I thought it'd be rather easy actually.. but alas, it requires reg exp's - one of my pet hates; just below class's.

Anyway, the code im using:
$_string = file_get_contents(""); // myspace file.

$_reg = '#\"http://(.*)\"#'; // regular expression

preg_match($_reg, $_string, $_match);
echo htmlentities($_match[0]);
This works... but it gives me this:
Expand|Select|Wrap|Line Numbers
  1. "" /><meta http-equiv="expires" content="0" /><meta http-equiv="Pragma" content="no-cache"
when what i actually want is:
Expand|Select|Wrap|Line Numbers
  1. ""
It stretches to the last quote on the current line.. when i want the first quote that comes after href=

Any ideas?
Feb 8 '08 #1
Share this Question
Share on Google+
1 Reply

P: 14
Instead of matching with .*, you could match with [^\"]*. That way you will only match until first occurence of \".
Expand|Select|Wrap|Line Numbers
  1. $_reg = '#\"http://([^\"]*)\"#'; // regular expression
Mar 30 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.