Highlight str
ik ben met een uber moeilijk project bezig(voor mij dan).
Wat ik wil is:
css
javascript
html
liefst ook asp
higliten net zoals php
voor css heb ik het wel maar de code ziet er niet uit
voor javascript ben ik een heel eind maar nog lange
niet klaaar wie kan mij helpen of op gang helpen of
een site verwijzen
de code die ik nu heb voor css:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?
$output = preg_replace('[\.(.*?)\{]', '<i>.$1 {</i>', $output);
$output = preg_replace('/(.*?)\{/', '<i>$1 {</i>', $output);
$output = preg_replace('/(.*)\:/', '<em>$1</em><i>:</i>', $output);
$output = preg_replace('/:(.*)\;/', ':<b>$1</b><i>;</i>', $output);
$output = preg_replace('/}/', '<i>}</i>', $output);
$output = preg_replace("/\n/", "<br/>", $output);
$output = preg_replace("/\t/", " ", $output);
echo '
<!--remove-->
<style type="text/css">
html{
border: 1px solid;
height: 95%;
width: 99%;
font-size: 12;
font-family: Courier New;
}
i {color: #FF00FE;font-style: normal;}
em {color: #000098; font-style: normal;}
b {color: #0001FE; font-weight: normal;}
</style>
<!--remove-->
';
echo $output;
echo '<br/><--GO-->';
}
?>
$output = preg_replace('[\.(.*?)\{]', '<i>.$1 {</i>', $output);
$output = preg_replace('/(.*?)\{/', '<i>$1 {</i>', $output);
$output = preg_replace('/(.*)\:/', '<em>$1</em><i>:</i>', $output);
$output = preg_replace('/:(.*)\;/', ':<b>$1</b><i>;</i>', $output);
$output = preg_replace('/}/', '<i>}</i>', $output);
$output = preg_replace("/\n/", "<br/>", $output);
$output = preg_replace("/\t/", " ", $output);
echo '
<!--remove-->
<style type="text/css">
html{
border: 1px solid;
height: 95%;
width: 99%;
font-size: 12;
font-family: Courier New;
}
i {color: #FF00FE;font-style: normal;}
em {color: #000098; font-style: normal;}
b {color: #0001FE; font-weight: normal;}
</style>
<!--remove-->
';
echo $output;
echo '<br/><--GO-->';
}
?>
Code voor javascript:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?
$str = "<script language=\"javascript\">
<!--
//
/*
*/
alert('LAL12312asddadshgasdgasdgakjdgsklajhsdlkjha43785687345kjhdskjhsdlfkhsldkufyil5k3jh45lkjhsdlfuhlskhfklshfuhe2l3');
prompt('lal');
function loletjes(){
asdasda
}
</script>";
//$out = preg_replace('/(&|=|\+|\*|\^|%|!|-|\?)/','<span style="color: #0402FC">$1</span>',$out);
$out = str_replace('<','<',$str);
$out = str_replace('>','>',$out);
$out = preg_replace('/\n/','<br/>',$out);
$out = ereg_replace('<script(.*)(["| ])>','<span style="color: #9C0204"><script \\1\\2></span>',$out);
$out = preg_replace('/"([a-z|A-Z]{1,18})"/','<span style="color: #0402FC">"\\1"</span>',$out);
$out = ereg_replace('<\/script>','<span style="color: #9C0204"></script></span>',$out);
$out = ereg_replace('function','<strong>function</strong>',$out);
$out = preg_replace('/\(([\'|"])([a-z|A-Z|1-9|]+)([\'|"])\)/','(<span style="color: #0402FC">\\1\\2\\3</span>)',$out);
$out = ereg_replace('\{','<span style="color: #04029C;font-weight:bold">{</span>',$out);
$out = ereg_replace('\}','<span style="color: #04029C;font-weight:bold">}</span>',$out);
$out = ereg_replace('\(','<span style="color: #04029C;font-weight:bold">(</span>',$out);
$out = ereg_replace('\)','<span style="color: #04029C;font-weight:bold">)</span>',$out);
$out = ereg_replace('alert','<span style="color: #9C029C">alert</span>',$out);
$out = ereg_replace('prompt','<span style="color: #9C029C">prompt</span>',$out);
$out = ereg_replace('confirm','<span style="color: #9C029C">confirm</span>',$out);
$out = ereg_replace('close','<span style="color: #9C029C">close</span>',$out);
$out = ereg_replace('go','<span style="color: #9C029C">go</span>',$out);
$out = ereg_replace('document','<span style="color: #9C029C">document</span>',$out);
$out = ereg_replace('all','<span style="color: #9C029C">all</span>',$out);
echo $out;
?>
$str = "<script language=\"javascript\">
<!--
//
/*
*/
alert('LAL12312asddadshgasdgasdgakjdgsklajhsdlkjha43785687345kjhdskjhsdlfkhsldkufyil5k3jh45lkjhsdlfuhlskhfklshfuhe2l3');
prompt('lal');
function loletjes(){
asdasda
}
</script>";
//$out = preg_replace('/(&|=|\+|\*|\^|%|!|-|\?)/','<span style="color: #0402FC">$1</span>',$out);
$out = str_replace('<','<',$str);
$out = str_replace('>','>',$out);
$out = preg_replace('/\n/','<br/>',$out);
$out = ereg_replace('<script(.*)(["| ])>','<span style="color: #9C0204"><script \\1\\2></span>',$out);
$out = preg_replace('/"([a-z|A-Z]{1,18})"/','<span style="color: #0402FC">"\\1"</span>',$out);
$out = ereg_replace('<\/script>','<span style="color: #9C0204"></script></span>',$out);
$out = ereg_replace('function','<strong>function</strong>',$out);
$out = preg_replace('/\(([\'|"])([a-z|A-Z|1-9|]+)([\'|"])\)/','(<span style="color: #0402FC">\\1\\2\\3</span>)',$out);
$out = ereg_replace('\{','<span style="color: #04029C;font-weight:bold">{</span>',$out);
$out = ereg_replace('\}','<span style="color: #04029C;font-weight:bold">}</span>',$out);
$out = ereg_replace('\(','<span style="color: #04029C;font-weight:bold">(</span>',$out);
$out = ereg_replace('\)','<span style="color: #04029C;font-weight:bold">)</span>',$out);
$out = ereg_replace('alert','<span style="color: #9C029C">alert</span>',$out);
$out = ereg_replace('prompt','<span style="color: #9C029C">prompt</span>',$out);
$out = ereg_replace('confirm','<span style="color: #9C029C">confirm</span>',$out);
$out = ereg_replace('close','<span style="color: #9C029C">close</span>',$out);
$out = ereg_replace('go','<span style="color: #9C029C">go</span>',$out);
$out = ereg_replace('document','<span style="color: #9C029C">document</span>',$out);
$out = ereg_replace('all','<span style="color: #9C029C">all</span>',$out);
echo $out;
?>
Wie kan mij helpen
Gewijzigd op 04/01/2006 13:40:00 door ColdDoT
Aantal array's maken met worden of tekens, en dabn foreachen en in die foreach gaan string replacen.
Ok ik ga nu proberen
Nop niet gelukt ik laat eerst zo en dan zet ik wel een keer naar array