I have this string:
Page 1 Page 2 Sub Page A
That's not "a string", it's HTML. You need to use an HTML parser like DOMDocument or simple_html_dom.
See examples at http://htmlparsing.com/php.html