Question: I have a HTML fragment which contains two anchor tags in various parts of the HTML. 

```
<span id="ctl00_PlaceHolderTitleBreadcrumb_ContentMap">
    <span><a class="ms-sitemapdirectional" href="/">My Site</a></span>
    <span> &gt; </span>
    <span><a class="ms-sitemapdirectional" href="/Lists/Announcements/AllItems.aspx">Announcements</a></span>
    <span> &gt; </span>
    <span class="ms-sitemapdirectional">Settings</span>
</span>

```

I'm looking to write a regular expression that will return the second anchor tag, which has 'Announcements' as it's text. In trying to write an expression, I keep getting both anchor tags returned - but I'm only interested in the second tag.

Is it possible to match the second tag only?

**EDIT:**

I will always know that I'm looking for an anchor tag which has 'Announcements' in it's text, if that helps.

Answer: 
like

```
   /<a.+?>[^<>]*Announcements[^<>]*</a>/

```

PS. regular expression are the wrong tool for parsing html
```
<?php
$string = '<span id="ctl00_PlaceHolderTitleBreadcrumb_ContentMap"><span><a class="ms-sitemapdirectional" href="/">My Site</a></span><span> &gt; </span><span><a class="ms-sitemapdirectional" href="/Lists/Announcements/AllItems.aspx">Announcements</a></span><span> &gt; </span><span class="ms-sitemapdirectional">Settings</span></span>';

$dom = new DOMDocument();
$dom->loadHTML($string);
$anchors = $dom->getElementsByTagName('a');
if ( $anchors->length ) {
    $secondAnchor = $anchors->item(1);
    echo innerHTML($secondAnchor->parentNode);
}

function innerHTML($node){
    $doc = new DOMDocument();
    foreach ($node->childNodes as $child)
    $doc->appendChild($doc->importNode($child, true));

    return $doc->saveHTML();
}

```