Tag Archives: regular expression between html tag

Regular Expression to Parse Text Between Simple Tags (XML)

It is often necessary to extract text from a variable that contains HTML or XML code. I’ve created a simple regular expression that will help you to extract all text between certain tags into an array. It is a PHP solution, though regular expression is compatible with other programming languages. preg_match_all(“/<tag>(.*?)</tag>/”, $source, $results); This construsion will create an… Read More »