First of all, you are using /
as delimiters in your regex. This is fine but you'd have to escape the forward slashes inside the regex like this:
/<p class=\"psku\">SOMETHINGREGEX<\/span><\/p>/
If you're like me and think this looks messy, you can also choose to use a different character as delimiter:
@<p class=\"psku\">SOMETHINGREGEX</span></p>@
Additionally, what's inside your SOMETHINGREGEX
? I suspect it contains a dot (.
). To enable the dot to match newline characters, and stretch across multiple lines, you need to add the s
modifier:
@<p class=\"psku\">SOMETHINGREGEX</span></p>@s
However, like @konrados mentioned, using DOMDocument would be the best choice here. Using regex to parse HTML is very unreliable, as you have to account for a lot of formatting choices: tags written in capital letters, whitespace in places you wouldn't expect, etc. However, if you're certain that all your input is formatted in the same way, regex should do the trick.