diff --git a/forms/HtmlEditorField.php b/forms/HtmlEditorField.php
index f9f58e747..f5a72a74c 100644
--- a/forms/HtmlEditorField.php
+++ b/forms/HtmlEditorField.php
@@ -578,7 +578,7 @@ class HtmlEditorField_Toolbar extends RequestHandler {
// Similar to the regex found in HtmlEditorField.js / getAnchors method.
if (preg_match_all("/\s(name|id)=\"([^\"]+?)\"|\s(name|id)='([^']+?)'/im", $page->Content, $matches)) {
- $anchors = $matches[1];
+ $anchors = array_filter(array_merge($matches[2], $matches[4]));
}
} else {