FreeKB - A Regular Expression to clean up ckeditor html
A Regular Expression to clean up ckeditor html

Home > Search


The following patterns and replacements can be used to clean up the html created by ckeditor.

		$patterns = array();
		$patterns[0] = '/<p>/';
		$patterns[1] = '/<\/p>/';
		$patterns[2] = '/<strong>/';
		$patterns[3] = '/<\/strong>/';
		$patterns[4] = '/<img src="images\/.*png" \/>/';
		$patterns[5] = '/<img src="images\/.*png" style="border-style:solid; border-width:.*px" \/>/';	
		$patterns[6] = '/<img src="images\/.*png" style="border-style:solid; border-width:.*px; width:.*%" \/>/';
		$patterns[7] = '/<img alt="" src="images\/.*png" style="border-style:solid; border-width:.*px" \/>/';		
		$patterns[8] = '/<img src="images\/.*png" style="width:.*%" \/>/';

		$patterns[9] = '/<hr \/>/';		
		$patterns[10] = '/<ul>/';	
		$patterns[11] = '/<\/ul>/';		
		$patterns[12] = '/<ol>/';	
		$patterns[13] = '/<\/ol>/';		
		$patterns[14] = '/<li>/';	
		$patterns[15] = '/<\/li>/';	
		$patterns[16] = '/<p><strong>Issue<\/strong><\/p>/';			
		$patterns[17] = '/<table border=".*" cellpadding=".*" cellspacing=".*" class=".*" style="width:.*%">/';
		$patterns[18] = '/<\/table>/';
		$patterns[19] = '/<pre>/';	
		$patterns[20] = '/<\/pre>/';	
		$patterns[21] = '/<blockquote>/';	
		$patterns[22] = '/<\/blockquote>/';
		$patterns[23] = '/<i>/';
		$patterns[24] = '/<\/i>/';		
		$patterns[25] = '/<em>/';
		$patterns[26] = '/<\/em>/';
		
		$replacements = array();

		$replacements[1] = '';
		$replacements[2] = '';
		$replacements[3] = '';
		$replacements[4] = '';
		$replacements[5] = '';
		$replacements[6] = '';
		$replacements[7] = '';
		$replacements[8] = '';
		$replacements[9] = '';
		$replacements[10] = '';		
		$replacements[11] = '';	
		$replacements[12] = '';	
		$replacements[13] = '';				
		$replacements[14] = '';				
		$replacements[15] = '';	
		$replacements[16] = '';	
		$replacements[17] = '';	
		$replacements[18] = '';	
		$replacements[19] = '';	
		$replacements[20] = '';	
		$replacements[21] = '';	
		$replacements[22] = '';	
		$replacements[23] = '';	
		$replacements[24] = '';	
		$replacements[25] = '';	
		$replacements[26] = '';	

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 17fe2 in the box below so that we can be sure you are a human.




Comments