Reputation: 62366
preg_match('/<div class="prices">/s<h3>(.+?)<\/h3>/is', $response, $matches);
There's whitespace and potentially new lines between the prices div and the h3 tag. How do I use /s to match that?
Upvotes: 5
Views: 4852
Reputation: 838116
You don't use /s
, you use \s*
.
\
), not a slash (/
).*
afterwards means that it matches zero or more whitespace characters.Also, please consider using an HTML parser if you are trying to find HTML tags. A proper HTML parser will be able to correctly handle whitespace, HTML comments and other features of HTML that your regular expression cannot handle.
Upvotes: 8