Skip to content

Instantly share code, notes, and snippets.

@lthurston
Created December 29, 2010 23:35
Show Gist options
  • Save lthurston/759221 to your computer and use it in GitHub Desktop.
Save lthurston/759221 to your computer and use it in GitHub Desktop.
<?php
$aTag = '<a href="news-test/ams-list-dev.html#c131546" class="fancy-link" rel="131546">';
$regex = '/(href="[^#]+(#[A-Za-z0-9]+)")/';
if(preg_match($regex,$string,$matches)) {
$search = $matches[0];
$replace = 'href="'.$matches[2].'"';
$newATag = str_replace($search,$replace,$string);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment