* @return string
*/
public static function rm_endcomma($string) {
- return ereg_replace(',$','',$string);
+ return preg_replace('/,$/','',$string);
}
/**
* @see calcParenthesis()
*/
public static function calcPriority($string) {
- $string=ereg_replace('[[:space:]]*','',$string); // removing all whitespace
+ $string=preg_replace('/[ ]*/','',$string); // removing all whitespace
$string='+'.$string; // Ensuring an operator for the first entrance
$qm='\*\/\+-^%';
$regex = '(['.$qm.'])(['.$qm.']?[0-9\.]*)';
* @return string Converted result.
*/
public static function deHSCentities($str) {
- return ereg_replace('&([#[:alnum:]]*;)','&\1',$str);
+ return preg_replace('/&([#A-Za-z0-9]*;)/','&\1',$str);
}
/**
$name = '';
}
} else {
- if ($key = strtolower(ereg_replace('[^a-zA-Z0-9]','',$val))) {
+ if ($key = strtolower(preg_replace('/[^a-zA-Z0-9]/','',$val))) {
$attributes[$key] = '';
$name = $key;
}
* @internal
*/
public static function split_tag_attributes($tag) {
- $tag_tmp = trim(eregi_replace ('^<[^[:space:]]*','',trim($tag)));
+ $tag_tmp = trim(preg_replace ('/^<[^[:space:]]*/i','',trim($tag)));
// Removes any > in the end of the string
- $tag_tmp = trim(eregi_replace ('>$','',$tag_tmp));
+ $tag_tmp = trim(preg_replace ('/>$/i','',$tag_tmp));
$value = array();
while (strcmp($tag_tmp,'')) { // Compared with empty string instead , 030102
}
// The tag name is cleaned up so only alphanumeric chars (plus - and _) are in there and not longer than 100 chars either.
- $tagName = substr(ereg_replace('[^[:alnum:]_-]','',$tagName),0,100);
+ $tagName = substr(preg_replace('/[^[:alnum:]_-]/','',$tagName),0,100);
// If the value is an array then we will call this function recursively:
if (is_array($v)) {
// Initialize variabels:
$filearray = array();
$sortarray = array();
- $path = ereg_replace('\/$','',$path);
+ $path = preg_replace('#\/$#','',$path);
// Find files+directories:
if (@is_dir($path)) {
$pString = t3lib_div::implodeArrayForUrl('',$params);
- return $pString ? $parts.'?'.ereg_replace('^&','',$pString) : $parts;
+ return $pString ? $parts.'?'.preg_replace('/^&/','',$pString) : $parts;
}
/**
list($v,$n) = explode('|',$GLOBALS['TYPO3_CONF_VARS']['SYS']['requestURIvar']);
$retVal = $GLOBALS[$v][$n];
} elseif (!$_SERVER['REQUEST_URI']) { // This is for ISS/CGI which does not have the REQUEST_URI available.
- $retVal = '/'.ereg_replace('^/','',t3lib_div::getIndpEnv('SCRIPT_NAME')).
+ $retVal = '/'.preg_replace('#^/#','',t3lib_div::getIndpEnv('SCRIPT_NAME')).
($_SERVER['QUERY_STRING']?'?'.$_SERVER['QUERY_STRING']:'');
} else {
$retVal = $_SERVER['REQUEST_URI'];
break;
case 'msie':
$tmp = strstr($useragent,'MSIE');
- $bInfo['VERSION'] = doubleval(ereg_replace('^[^0-9]*','',substr($tmp,4)));
+ $bInfo['VERSION'] = doubleval(preg_replace('/^[^0-9]*/','',substr($tmp,4)));
break;
case 'opera':
$tmp = strstr($useragent,'Opera');
- $bInfo['VERSION'] = doubleval(ereg_replace('^[^0-9]*','',substr($tmp,5)));
+ $bInfo['VERSION'] = doubleval(preg_replace('/^[^0-9]*/','',substr($tmp,5)));
break;
case 'konqu':
$tmp = strstr($useragent,'Konqueror/');
// BODGE: replace inline $mark characters in places where we want them ignored
// they will be put back after main substitutue, stops problems with eg, and/or
$bodge = chr(1);
- $line = eregi_replace( '([[:alnum:]])'.$mark.'([[:alnum:]])', '\\1'.$bodge.'\\2',$line );
+ $line = preg_replace( '/([[:alnum:]])'.$mark.'([[:alnum:]])/i', '\\1'.$bodge.'\\2',$line );
- $regex = '(^| |[(.,])'.$mark.'([^'.$mark.']*)'.$mark.'([^[:alnum:]]|$)';
+ $regex = '/(^| |[(.,])'.$mark.'([^'.$mark.']*)'.$mark.'([^[:alnum:]]|$)/i';
$replace = '\\1<'.$tag.'>\\2</'.$tag.'>\\3';
- $line = eregi_replace( $regex, $replace, $line );
+ $line = preg_replace( $regex, $replace, $line );
// BODGE: back we go
- $line = eregi_replace( $bodge, $mark, $line );
+ $line = preg_replace( '/'.$bodge.'/i', $mark, $line );
return $line;
}
// BODGE: replace inline $mark characters in places where we want them ignored
// they will be put back after main substitutue, stops problems with eg, and/or
$bodge = chr(1);
- $line = eregi_replace( '([[:alnum:]])'.$mark.'([[:alnum:]])', '\\1'.$bodge.'\\2',$line );
+ $line = preg_replace( '/([[:alnum:]])'.$mark.'([[:alnum:]])/i', '\\1'.$bodge.'\\2',$line );
- $regex = '(^| |[(.,])'.$mark.'([^'.$mark.']*)'.$mark.'([^[:alnum:]]|$)';
+ $regex = '/(^| |[(.,])'.$mark.'([^'.$mark.']*)'.$mark.'([^[:alnum:]]|$)/i';
$replace = '\\1'.$tag.'\\2'.$tag.'\\3';
- $line = eregi_replace( $regex, $replace, $line );
+ $line = preg_replace( $regex, $replace, $line );
// BODGE: back we go
- $line = eregi_replace( $bodge, $mark, $line );
+ $line = preg_replace( '/'.$bodge.'/i', $mark, $line );
return $line;
}
// do regex for subscript and superscript (slightly different)
// $mark is the magic character and $tag the HTML tag to insert
- $regex = $mark.'([^'.$mark.']*)'.$mark;
+ $regex = '/'.$mark.'([^'.$mark.']*)'.$mark.'/i';
$replace = '<'.$tag.'>\\1</'.$tag.'>';
- return eregi_replace( $regex, $replace, $line );
+ return preg_replace( $regex, $replace, $line );
}
function do_list( $line, $blank=false ) {
else {
$listchar = $line{0};
$count = strspn( $line, $listchar );
- $line = eregi_replace( "^[".$listchar."]+ ", "", $line );
+ $line = preg_replace( "/^[".$listchar."]+ /i", "", $line );
}
// find what sort of list this character represents
$line = str_replace( "1/4", "¼", $line );
$line = str_replace( "1/2", "½", $line );
$line = str_replace( "3/4", "¾", $line );
- $line = eregi_replace( "([[:digit:]]+[[:space:]]*)x([[:space:]]*[[:digit:]]+)", "\\1×\\2", $line ); // (digits) x (digits) - multiply
+ $line = preg_replace( "/([[:digit:]]+[[:space:]]*)x([[:space:]]*[[:digit:]]+)/i", "\\1×\\2", $line ); // (digits) x (digits) - multiply
// do formatting tags
// NOTE: The / replacement *has* to be first, or it will screw the
// HTML tags that are added by the other ones
// convert urls into proper link with optional link text URL(text)
// MARDOWN: HTML conversion should work fine
- $line = eregi_replace("([[:space:]]|^)([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])\(([^)]+)\)",
+ $line = preg_replace("/([[:space:]]|^)([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])\(([^)]+)\)/i",
"\\1[\\5](\\2://\\3\\4)", $line);
- $line = eregi_replace("([[:space:]])www\.([^[:space:]]*)([[:alnum:]#?/&=])\(([^)]+)\)",
+ $line = preg_replace("/([[:space:]])www\.([^[:space:]]*)([[:alnum:]#?/&=])\(([^)]+)\)/i",
"\\1[\\5](http://www.\\2\\3)", $line);
// make urls (with and without httpd) into proper links
- $line = eregi_replace("([[:space:]]|^)([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])",
+ $line = preg_replace("/([[:space:]]|^)([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])/i",
"\\1<\\2://\\3\\4>", $line);
- $line = eregi_replace("([[:space:]])www\.([^[:space:]]*)([[:alnum:]#?/&=])",
+ $line = preg_replace("/([[:space:]])www\.([^[:space:]]*)([[:alnum:]#?/&=])/i",
"\\1<http://www.\\2\\3\>", $line);
// make email addresses into mailtos....
// MARKDOWN doesn't quite support this, so do as html
- $line = eregi_replace("([[:space:]]|^)([[:alnum:]._-]+@[[:alnum:]._-]+)\(([^)]+)\)",
+ $line = preg_replace("/([[:space:]]|^)([[:alnum:]._-]+@[[:alnum:]._-]+)\(([^)]+)\)/i",
"\\1<a href=\"mailto:\\2\">\\3</a>", $line);
// !# at the beginning of any lines means a heading
// MARKDOWN: value (1-6) becomes number of hashes
- if (eregi( "^!([1-6]) (.*)$", $line, $regs )) {
+ if (preg_match( "/^!([1-6]) (.*)$/i", $line, $regs )) {
$depth = substr( $line, 1, 1 );
$out = substr( '##########', 0, $depth);
- $line = eregi_replace( "^!([1-6]) (.*)$", "$out \\2", $line );
+ $line = preg_replace( "/^!([1-6]) (.*)$/i", "$out \\2", $line );
}
// acronym handing, example HTML(Hypertext Markyp Language)
// MARKDOWN: no equiv. so just leave as HTML
- $line = ereg_replace( "([A-Z]+)\(([^)]+)\)", "<acronym title=\"\\2\">\\1</acronym>", $line );
+ $line = preg_replace( "/([A-Z]+)\(([^)]+)\)/", "<acronym title=\"\\2\">\\1</acronym>", $line );
// Replace resource link >>##(Description Text)
// MARKDOWN: change to MD web link style
- $line = eregi_replace( " ([a-zA-Z]+):([0-9]+)\(([^)]+)\)",
+ $line = preg_replace("/ ([a-zA-Z]+):([0-9]+)\(([^)]+)\)/i",
" [\\3](".$CFG->wwwroot."/mod/\\1/view.php?id=\\2) ", $line );
require_once($CFG->libdir.'/filelib.php');
$coursefileurl = get_file_url($this->courseid);
// Replace picture resource link
- $line = eregi_replace( "/([a-zA-Z0-9./_-]+)(png|gif|jpg)\(([^)]+)\)",
+ $line = preg_replace("#/([a-zA-Z0-9./_-]+)(png|gif|jpg)\(([^)]+)\)#i",
"", $line );
// Replace file resource link
- $line = eregi_replace( "file:/([[:alnum:]/._-]+)\(([^)]+)\)",
+ $line = preg_replace("#file:/([[:alnum:]/._-]+)\(([^)]+)\)#i",
"[\\2](".$coursefileurl."/\\1)", $line );
return $line;
if (eregi("^\% ",$line) ) {
// preformatted text - no processing
// MARKDOWN: this is MD code form of a paragraph
- $buffer = $buffer . " " . eregi_replace( "^\%","",$line) . "\n";
+ $buffer = $buffer . " " . preg_replace( "/^\%/i","",$line) . "\n";
$this->block_state = STATE_NOTIKI;
}
else {