Have some more optimizations:
Code: <?php
//Optimizations Start
//minor things
$match = array('While 0=', '(1/2)', '(1/4)', '(1/5)', '(1/10)', '(1/20)', '(1/30)', '(1/40)', '3^3', '4^3', '^2', '^3');//keep going, find a better way
$replace = array('��While not(', '��.5', '��.75', '��.2', '��.1', '��.2', '��.3', '��.4', '��27', '��64', '���', '���');
$string = repstr($match, $replace, $string);
$match = array ('@([0-9])\*([A-Z|�])@', '@([A-Z|�])\*([0-9])@', '@([0-9|A-Z|�])/\(([0-9|A-Z|�])\)@', '@�\^\(?@', '@10\^\(?@', '@Output\(1,1,"([[:alnum:]]{1,16})@');
$replace = array ('��\1\2', '��\1\2', '��\1/\2', '���^(', '���^(', '��Disp "\1');
$string = repreg($match, $replace, $string);
// Extra zeros to E^
//positive
$match = array('@([2-9])000([�|�|:|\)|/|\*|,|\^])@', '@([2-9])0000([�|�|:|\)|/|\*|,|\^])@', '@([2-9])00000([�|�|:|\)|/|\*|,|\^])@');
$replace = array('��\1�3\2', '��\1�4\2', '��\1�5\2');
$string = repreg($match, $replace, $string);
$match = array('@100([�|�|:|\)|/|\*|,|\^])@', '@1000([�|�|:|\)|/|\*|,|\^])@', '@10000([�|�|:|\)|/|\*|,|\^])@', '@100000([�|�|:|\)|/|\*|,|\^])@');
$replace = array('���2\1', '���3\1', '���4\1', '���5\1');
$string = repreg($match, $replace, $string);
//negative
$match = array('@([�|�|:|\)|/|\*|,|\^])\.001([�|�|:|\)|/|\*|,|\^])@', '@([�|�|:|\)|/|\*|,|\^])\.0001([�|�|:|\)|/|\*|,|\^])@', '@([�|�|:|\)|/|\*|,|\^])\.00001([�|�|:|\)|/|\*|,|\^])@');
$replace = array('��\1��3\2', '��\1��4\2', '��\1��5\2');
$string = repreg($match, $replace, $string);
$match = array('@([�|�|:|\)|\(|/|\*|,|\^])\.000([1-9])([�|�|:|\(|\)|/|\*|,|\^])@', '@([�|�|:|\)|\(|/|\*|,|\^])\.0000([1-9])([�|�|:|\(|\)|/|\*|,|\^])@', '@([�|�|:|\(|\)|/|\*|,|\^])\.00000([1-9])([�|�|:|\(|\)|/|\*|,|\^])@');
$replace = array('��\1\2��4\3', '��\1\2��5\3', '��\1\2��6\3');
$string = repreg($match, $replace, $string);
//For 1 inc, if h, reciprocal
$match = array ('@For\(([A-Z|�]),([[:alnum:]]{0,7}),([[:alnum:]]{0,7}),1@', '@([[:alnum:]]{0,})/([A-Z|�])\^([[:alnum:]{0,}])@');
$replace = array ('��For(\1,\2,\3', '��\1\2^�\3');
$string = repreg($match, $replace, $string);
//extra multiplication and division characters
$match = array ('@([0-9])\*([A-Z|�])@', '@([A-Z|�])\*([0-9])@', '@([0-9|A-Z|�])/\(([0-9|A-Z|�])\)@', '@([�|�|:|\)|/|\*|,|\^])1([A-Z|�])@');
$replace = array ('��\1\2', '��\1\2', '��\1/\2', '��\1\2');
$string = repreg($match, $replace, $string);
//end$ or ^start of prog
$match = array ('@Output\(1,1," $@');
$replace = array ('��Output(1,1,"');
$string = repreg($match, $replace, $string);
//Delvars, if X!=0, removal of lagging "}), if not
$match = array ('@([:|�])0�(.*?)[:|�]@', '@(DelVar [0-9|A-Z|�])[:|�](DelVar [0-9|A-Z|�])[:|�|[:blank:]]@', '@(If [A-Z|�])�0@', '@If not\(([A-Z|�])=([A-Z|�]) and ([A-Z|�])=([A-Z|�])@');
$replace = array ('\1��Delvar \2', '��\1\2', '��\1', '��If \1�\2 or \3�\4', '��\2');
$string = repreg($match, $replace, $string);
//Disps
// $match = array ('@(Disp "(.*?)):Disp ([["(.*?)|[A-Z]|�|!])@', '@Disp ([["(.*?)|[A-Z]|�|!])[:|�]Pause ([:|�])@');
$replace = array ('��\1",\3', '��Pause \1\2');
$string = repreg($match, $replace, $string);
//Disp numbers, -A+B, A^(1/B
$match = array('@Disp "([[:digit:]]{1,})(")?(:|�)@', '@�([A-Z|�])\+([A-Z|�])�([A-Z|�])@', '@(�|�|:|\()([A-Z|�])\^\(1\/([A-Z|�])(�|�|:)@');
$replace = array('��Disp \1\3', '��\2-\1�\3', '��\1\3��(\2');
$string = repreg($match, $replace, $string);
//2A/(2BA, 1/(4/A, If not(A) and not(B
$match = array('@(�|�|:|\()([1-9])([A-Z|�])/\(\2([A-Z|�])\3(�|�|:)@', '@(�|�|:)1/\(([A-Z|�|1-9])/([A-Z|�|1-9])(�|�|:)@', '@(If|While|Repeat) not\((.*?)\) and not\((.*?)(�|�|:)@');
$replace = array('��\1\4�\5', '��\1\3/\2\4', '��\1 not(\2 or \3');
$string = repreg($match, $replace, $string);
//If not(A=B is not working
// $match = array('@(If|While|Repeat) not\((.*?)\=(.*?)(�|�|:)@', '@(If|While|Repeat) not\((.*?)\�(.*?)(�|�|:)@', '@(If|While|Repeat) not\((.*?)\�(.*?)(�|�|:)@', '@(If|While|Repeat) not\((.*?)�(.*?)(�|�|:)@');
$replace = array('��\1 \2�\3\4', '��If \1=\2\3', '��\1 \2>\3\4', '��\1 \2<\3\4');
$string = repreg($match, $replace, $string);
//7112->A:7112->B, Disp "Guess?:Prompt A, If (A) or (X)
$match = array('@(�|:)([[:alnum:]]{0,})�([A-Z|�])(�|:)\2�([A-Z|�])@', '@Disp "(.*?):Prompt ([A-Z|�])@', '@(If|While|Repeat) \((.*?)\) (and|or|xor) \((.*?)\)@');
$replace = array('��\1\2�\3\4\3�\5', '��Input "\1",\2', '��\1 \2 \3 \4');
$string = repreg($match, $replace, $string);
//If A and|or B
$match = array('@(If|While|Repeat) (.*?) and (.*?)(:|�)@', '@(If|While|Repeat) (.*?) or (.*?)(:|�)@', '@(If|While|Repeat) (.*?)=([0-9]) and (.*?)�\3 or \2�\3 and \4=\3(:|�)@');
$replace = array('��\1 \2\3\4', '��\1 \2/\3\4', '��\1 \2=\3 xor \4=\3');
$string = repreg($match, $replace, $string);
//If A=10 and|or B=10, If A>B or A<B
$match = array('@(If|While|Repeat) (.*?)=(.*?) and (.*?)=\3@', '@(If|While|Repeat) (.*?)=(.*?) or (.*?)=\3@', '@(If|While|Repeat) (.*?)=(.*?) and (.*?)=(.*?) or \2=(.*?) and \4=(.*?)@', '@(If|While|Repeat) (.*?)>(.*?) or \2<\3@');
$replace = array('��\1 min(\3={\2,\4', '��\1 max(\3={\2,\4', '��\1 max(\2={\3,\6} and \3={\4,\7', '��If \2�\3');
$string = repreg($match, $replace, $string);
//If B:Then:"Str1 etc, Input "X" X,
$match = array ('@If ([A-Z|�])(:|�)Then(:|�)(.*?)�(A-Z|�)(:|�)Else(:|�)(.*?)�\5(:|�)End@', '@Input "([A-Z|�])(�|=?)",\1@');
$replace = array ('��\8�\5\3If \1\2\8�\5', '��Prompt \1');
$string = repreg($match, $replace, $string);
//For(X,5,1,-1
$match = array ('@For\((.*?),(.*?),(.*?),�1(:|�)@');
$replace = array ('��For(\1,\3,\2\4');
$string = repreg($match, $replace, $string);
//stuff with del, or not
$string = repreg('@Disp "(:|�)@', 'Disp ""\1', $string);
$string = repreg('@(["|\)|\}])(��|)@', '��[del]', $string);
$match = array ('@[:|�]$@', '@Stop$@', '@(["|\)|\}])(�|:|�|$)@','@:(:+)@');
$replace = array ('��[del]', '��[del]', '��[del]\2',':');
$string = repreg($match, $replace, $string);
//Optimizations End
?>
Also, "replace(/0->/g,"DelVar ");" is really dangerous when you set a list with only the element 0, like {0->L1.