I need to capture the name of an anchor html tag with regex and php so from text I will get "hello" (the name of the anchor)
Tried that:
$regex  = '/(?<=name\=")#([^]+?)#(?=")/i';  
preg_match_all($regex, $content, $data);
print_r($data);
I've tailed the apache error log to find out that:
PHP Warning: preg_match_all(): Compilation failed: missing terminating ] for character class at offset 26
also tried:
$regex  = '/(?<=name\=")([^]+?)(?=")/i'; 
$regex  = '/(?<=name\=")[^]+?(?=")/i'; 
which are basically the same. I guess I'm missing something, probably a silly slash or something like that but I'm not sure as to what
Will appreciated any help Thanks
SOLVED
Ok, Thanks to @stillstanding and @Gordon I've managed to do that with DOMDocument which is much simple so, for the record, Here is the Snippet
$dom = new DOMDocument;
    $dom->loadHTML($content);
    foreach( $dom->getElementsByTagName('a') as $node ) {
        echo $node->getAttribute( 'name' );
    }
 
     
     
     
     
    