PHP Snippet of regex usage to review

function replace_mobile_links( $content )
{			//return $content;
//			preg_match_all( "/<a href=.*<\/a>/i", $content, $matches);
//			"|<a.*(?=href=\"([^\"]*)\")[^>]*>([^<]*)</a>|i"
//			preg_match_all( "|<a.*(?=href=\"([^\"]*)\")[^>]*>([^<]*)</a>|i", $content, $matches);

			preg_match_all( "/<a.*<\/a>/iU", $content, $matches);
			
		if (   isset( $matches[0]) && is_array( $matches[0]) && (count( $matches[0]) > 0)   )
			foreach ( $matches[0] as $match )
			{
				$link_content = extract_content_from_link2( $match );
				
				if ( preg_match("/contact-us/iU", $match) ) //contact us links found
				{						
					$content = str_replace ( $match, "<a href='index.php?page=contact_us'>$link_content</a>", $content );
				}
				elseif ( preg_match( "/Support-Tickets/iU", $match ))
				{
					$content = str_replace ( $match, "<a href='index.php?page=account'>$link_content</a>", $content );
				}
							
				elseif ( preg_match( "#section/FAQ/1241654055#iU", $match ) )
				{		
					$created_url = "index.php?page=faq&category_id=3";				
					$content = str_replace ( $match, "<a href='{$created_url}'>$link_content</a>", $content );			
				}
				
				elseif ( preg_match( "#English/section/FAQ#iU", $match ))
				{
					
					if ( preg_match( "#href=\"/(.*)/\"#iU", $match, $ts ) )
					{
						$elements = explode( "/", $ts[1] );
						$article_L_title = array_pop( $elements );
						
						$article_L_title = urldecode( preg_replace( "/\+/U", " ", $article_L_title ) );
						
						$result = mysql_query( "SELECT time_id FROM laptopscreen_articles WHERE article_title LIKE '%$article_L_title%'" ) or die ( mysql_error() );
						
						if ( $row = mysql_fetch_array( $result ))
						{
							$created_url = "index.php?page=faq&article_id={$row['time_id']}";
						}
						else
							$created_url = "index.php?page=faq";
					}
					else
					{
						$created_url = "index.php?page=faq";
					}
					
					$content = str_replace ( $match, "<a href='{$created_url}'>$link_content</a>", $content );
					
				}  //   elseif ( preg_match( "#English/section/FAQ#iU", $match ))
				
				elseif ( preg_match( "#laptopscreen_viewer.php#iU", $match ) )
				{
					if ( preg_match( "#view_article=(.*)&#iU", $match, $extracted ))
					{
						$article_number = trim( $extracted[1] );
						$created_url = "index.php?page=faq&article_id=$article_number";
					}
					else $created_url = "index.php?page=faq";
		
					$content = str_replace ( $match, "<a href='{$created_url}'>$link_content</a>", $content );		
				}
					
			}  //foreach through all found links  
			
//		echo $content;
//		die();
		return $content;	
		
}

function extract_content_froml_link( $link )
{
	$link_content = preg_replace('/<a.*">/is',"", $link);
	$link_content = preg_replace('#</a>#is', "", $link_content);
	return $link_content;
}

function extract_content_from_link2 ( $link )
{
	if ( preg_match('#<a.+>(.+)</a>#Ui', $link, $matches ) > 0 )
	{
		return $matches[1];
	}
	else return false;
}