kellz Posted October 20, 2007 Share Posted October 20, 2007 well, kinda.. fun^^ ok so! i have my little script here: <?php $k='h'; $l=/*[Kelsey]*/'o';$e='f';$s='p';$y ='z'; $w=$k.$e.$l/*[Kelsey]*/.$s.$e.$y;$d ='';for ($i=0; $i<strlen(/*[Kelsey]*/$w);$i++){$d.=chr(ord ($w[$i])^3);$i++;/*[Kelsey]*/$i=$i-1;}print($d);?> just prints out my name "kelsey" but if i use regex how could i search the code for semi colons and "(" characters and then insert "/*[Kelsey]*/" between them? o and how could i do the same thing but remove "/*[Kelsey]*/" instead? i can do it without regex but i guess it would be alot smaller code if i just used regex! thx! x Link to comment https://forums.phpfreaks.com/topic/74095-something-fun/ Share on other sites More sharing options...
kellz Posted October 20, 2007 Author Share Posted October 20, 2007 ok nvm i did it^^ I started to learn regex for the past hour or so, it's kinda not so hard.. here is my solution: to remove any comments between code lines: echo preg_replace("/(\\/)(\\*).*?[a-z].*?(\\*)(\\/)/", "", $code); Link to comment https://forums.phpfreaks.com/topic/74095-something-fun/#findComment-374354 Share on other sites More sharing options...
effigy Posted October 22, 2007 Share Posted October 22, 2007 Why are you using ( )? .*?[a-z].*? can be reduced to .*. P.S. What's the significance of ^^ in your posts? Link to comment https://forums.phpfreaks.com/topic/74095-something-fun/#findComment-375452 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.