removeTrailingPunctuation($trimmed_text).$trim_chars; } } /** * Strip trailing punctuation from a line of text. * * @param string $text - The text to have trailing punctuation removed from. * * @return string - The line of text with trailing punctuation removed. */ private function removeTrailingPunctuation($text) { return preg_replace("'[^a-zA-Z_0-9]+$'s", '', $text); } /** * Make clean url * * @param string $text - the url * * @return string the url without special chars */ public function cleanURL($text) { global $search; global $replace; $search = array ('.','/','\\','*','-','+','=','^','~','`','','"',"'",'&',',',' ','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','?','!','@','#','$','%','','&','*','(',')','','','','|','','}','{','[',']',':',';','"','"'); $replace = array ('','','','','','','','','','','','',"",'e','','-','c','a','a','a','a','a','e','e','e','e','i','i','i','i','o','o','o','o','o','u','u','u','u','C','A','A','A','A','A','E','E','E','E','I','I','I','I','O','O','O','O','O','U','U','U','U','','','','','','','','','','','','','','','','','','','','','','','',''); return str_replace($search, $replace, $text); } /** * Check if the string is a valid email * * @param string $addr - the email * * @return boolean */ public function emailCheck($addr) { if (!ereg("^([0-9,a-z,A-Z]+)([.,_]([0-9,a-z,A-Z]+))*[@]([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[.]([0-9,a-z,A-Z]){2}([0-9,a-z,A-Z])?$", $addr)) { return false; } else { return true; } } public function getMonthName($month, $trim = false) { if ($trim == false) { switch ($month) { case 1 : return "Janeiro"; break; case 2 : return "Fevereiro"; break; case 3 : return "Maro"; break; case 4 : return "Abril"; break; case 5 : return "Maio"; break; case 6 : return "Junho"; break; case 7 : return "Julho"; break; case 8 : return "Agosto"; break; case 9 : return "Setembro"; break; case 10 : return "Outubro"; break; case 11 : return "Novembro"; break; case 12 : return "Dezembro"; break; } } else { switch ($month) { case 1 : return "Jan"; break; case 2 : return "Fev"; break; case 3 : return "Mar"; break; case 4 : return "Abr"; break; case 5 : return "Mai"; break; case 6 : return "Jun"; break; case 7 : return "Jul"; break; case 8 : return "Ago"; break; case 9 : return "Set"; break; case 10 : return "Out"; break; case 11 : return "Nov"; break; case 12 : return "Dez"; break; } } } public function getWeekDay($day) { switch ($day) { case 0 : return "Domingo"; break; case 1 : return "Segunda"; break; case 2 : return "Tera"; break; case 3 : return "Quarta"; break; case 4 : return "Quinta"; break; case 5 : return "Sexta"; break; case 6 : return "Sbado"; break; } } public function hyperlink($string) { #Procura pelo protocolo http://... $string = ereg_replace("[a-zA-Z]+://([.]?[a-zA-Z0-9_/-])*", "\\0", $string); #Procura pelo dominio.extensao... $string = ereg_replace("(^| )(www([.]?[a-zA-Z0-9_/-])*)", "\\1\\2", $string); #Retorno return $string; } /* Faz o replace somente uma vez na string. echo str_replace_once("-","","REFX-11-MANUAL"); Resulta em REFX11-MANUAL */ public function str_replace_once($search, $replace, $subject) { if(($pos = strpos($subject, $search)) !== false) { $ret = substr($subject, 0, $pos).$replace.substr($subject, $pos + strlen($search)); } else { $ret = $subject; } return($ret); } } ?>