How do I fix this preg match snippet

Experts,
I attempted to use the solution in the previous post, and received two errors.

Warning: Unexpected character in input: ''' (ASCII=39) state=1 in /pulldata.php on line 4

Parse error: syntax error, unexpected T_STRING in /pulldata.php on line 4


What I am attempting to do is capture the description between two <div> tags     >(.*)<

<div style="float:left; clear:both;">
                        The SonicWave DVI interconnect is designed for a state-of-the-art, no-compromise high-definition digital video connection. With SonicWave, you will experience absolute fidelity to the original video signal. Advanced cable design, top quality materials, and superior construction ensure a faultless digital experience and leave nothing to chance. Silver-plated oxygen-free copper conductors and nitrogen-foamed PE dielectric make this interconnect the right choice for the most demanding home cinema installations. 24K gold-plated connectors ensure superior signal transfer and a lifetime of precise, dependable performance. Two 80%+ OFC braids and 100% overlapped Mylar&reg; foil combine for full shielding against EMI/RFI interference. Don't compromise your high-definition signal; use the right interconnect! Each SonicWave DVI cable conforms completely to DVI-D specifications and DVI-D Dual Link bandwidth performance parameters. Tested to pass 1080p and CL2-rated for in-wall applications.<br/><br/><b>Connector 1:</b> DVI Male<br/><b>Connector 2:</b> DVI Male
                    </div>


Thanks for your help!!
//Original Code that returned the error

<?php
$strtest = '<a title="some title here" href="some url here">';
preg_match('%<a title=[\"]some title here[\"] href=([^`]*?)[\"]>%',$strtest,$extA);
'You should get the result: some url here.
echo $extA[1];
?>

Open in new window

rlb1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sudaraka WijesingheWeb Application ProgrammerCommented:
Does the errors indicated come from the sample code you have posted? It worked fine when I ran that code.

If you are looking for a regular expression to match text between tags try http://www.regular-expressions.info/examples.html
kaufmed   ( ⚆ _ ⚆ )I asked the operating system what I could do to become a better programmer. It said, "Let me give you some pointers."Commented:
Is your code posting literal? If so, line 6 would give you an error since quotation mark is not the comment character in php.
kaufmed   ( ⚆ _ ⚆ )I asked the operating system what I could do to become a better programmer. It said, "Let me give you some pointers."Commented:
P.S.

For the <div> tag, at least with what you posted above, you could use:
//Original Code that returned the error

<?php
$strtest = '<div style="float:left; clear:both;">The SonicWave DVI ... DVI Male</div>';
preg_match('%<div(?: [^>]*)?>(.*?)</div>%s',$strtest,$extA);
//You should get the result: some url here.
echo $extA[1];
?>

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray PaseurCommented:
The parse error you got was because the line was started with an apostrophe.  This is a valid comment character in some programming languages but not in PHP.  I usually use two slashes, like this code snippet.  IIRC you can use a # as well, and the /* ... */ notation works, too.

What you actually get from this script is:
"some url here

You might use this statement for the last, and you'd have a good solution:
echo trim($extA[1], '"');

Best regards, ~Ray
<?php // RAY_temp_rlb1.php
error_reporting(E_ALL);

$strtest = '<a title="some title here" href="some url here">';
preg_match('%<a title=[\"]some title here[\"] href=([^`]*?)[\"]>%',$strtest,$extA);
// 'You should get the result: some url here.
echo $extA[1];

Open in new window

rlb1Author Commented:
Thanks for your help!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.