I have some Plain Text/HTML Content like so:
Title: Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Snippet: Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Category: Lorem ipsum dolor sit amet, consectetur adipiscing elit.
and i want to match only the line where it says “Snippet: and the text that follows it, BUT ONLY on that line, nothing else, and also making the search case-insensitive. I tried with regular expressions, but ultimately i want to attempt using DOMDocument now, how can i do this?
I don’t know some details about your problem, so my answer might not be appropriate. You could decide based on the size of the content you need to parse that this is not an option. Also, from the question it is not clear where the html content comes into place, that is why I wrote this solution that doesn’t use DOM parsing.
A possible solution might be to get the lines that you want to parse in an array. After that you can filter the array, removing the lines that don’t match your rule from the result.
A sample would be:
that piece of code will return only one element in the $results array, the second line
you can see it at work here: http://codepad.org/220BLjEk