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 Quote Link to comment 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); Quote Link to comment 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.