parser

Написать ответ на текущее сообщение

 

 
   команды управления поиском

Нужна помощь в оптимизации кода

coel 06.02.2010 00:51

Как можно оптимизировать этот код на обработку смайлов? Кажется должен быть простой какой-то способ.
$smile1[^tLastComm.comment.match[8\)|8-\)|:cool:][gi]{<img src="/images/smilies/cool.gif" alt="8)" />}]
          $smile2[^smile1.match[:\)|:-\)|=\)|=-\)][gi]{<img src="/images/smilies/smile.gif" alt=":)" />}]
          $smile3[^smile2.match[:\(|:-\(|=\(|=-\(][gi]{<img src="/images/smilies/sad.gif" alt=":(" />}]
          $smile4[^smile3.match[:'\(|:"\(|='\(|="\(|:cry:][gi]{<img src="/images/smilies/cry.gif" alt=":'(" />}]
          $smile5[^smile4.match[>:\)|>:-\)|>=\)|>=-\)|:devil:|:angry:][gi]{<img src="/images/smilies/devil.gif" alt=">:)" />}]
          $smile6[^smile5.match[:ganja:][gi]{<img src="/images/smilies/ganja.gif" alt=":ganja:" />}]
          $smile7[^smile6.match[:ganja2:][gi]{<img src="/images/smilies/ganja2.gif" alt=":ganja2:" />}]
          $smile8[^smile7.match[:D|=D|:-D|=-D][gi]{<img src="/images/smilies/laugh.gif" alt=":D" />}]
          $smile9[^smile8.match[:lion:][gi]{<img src="/images/smilies/lion.gif" alt=":lion:" />}]
          $smile10[^smile9.match[xD|XD|x-D|X-D|:lol:][gi]{<img src="/images/smilies/lol.gif" alt="XD" />}]
          $smile11[^smile10.match[<3|<З|:heart:][gi]{<img src="/images/smilies/heart.gif" alt="<3" />}]
          $smile12[^smile11.match[:~\(|=~\(][gi]{<img src="/images/smilies/redface.gif" alt=":~(" />}]
          $smile13[^smile12.match[:relax:][gi]{<img src="/images/smilies/relax.gif" alt=":relax:" />}]
          $smile14[^smile13.match[:roll:][gi]{<img src="/images/smilies/roll.gif" alt=":roll:" />}]
          $smile15[^smile14.match[:shit:][gi]{<img src="/images/smilies/shit.gif" alt=":shit:" />}]
          $smile16[^smile15.match[:sick:][gi]{<img src="/images/smilies/sick.gif" alt=":sick:" />}]
          $smile17[^smile16.match[:smoke:][gi]{<img src="/images/smilies/smoke.gif" alt=":smoke:" />}]
          $smile18[^smile17.match[:spliff:][gi]{<img src="/images/smilies/spliff.gif" alt=":spliff:" />}]
          $smile19[^smile18.match[:rose:][gi]{<img src="/images/smilies/rose.gif" alt=":rose:" />}]
          $smile20[^smile19.match[:P|:-P|:Ъ|:-Ъ|=P|=-P|=Ъ|=-Ъ][gi]{<img src="/images/smilies/tongue.gif" alt=":P" />}]
          $smile21[^smile20.match[:whistle:][gi]{<img src="/images/smilies/whistle.gif" alt=":whistle:" />}]
          $smile22[^smile21.match[^;\)|^;-\)|:wink:][gi]{<img src="/images/smilies/wink.gif" alt="^;)" />}]
          $smile23[^smile22.match[O_O|o_O|O_o|О_О|О_о|о_О|o_o|о_о|:-O|=-O|:wow:][gi]{<img src="/images/smilies/wow.gif" alt=":-O" />}]
          $smile24[^smile23.match[:santa:][gi]{<img src="/images/smilies/santa.gif" alt=":santa:" />}]
          $smile25[^smile24.match[:rasta:][gi]{<img src="/images/smilies/rasta.gif" alt=":rasta:" />}]

          $bbBIU[^smile25.match[\[([biu])\](.+?)\[/\1\]][gi]{$match.2}]
          $bbCOLOR[^bbBIU.match[\[(color)=("?)([^^"]+?)\2\](.+?)\[/\1\]][gi]{${match.4}}]
          $bbURL[^bbCOLOR.match[\[(url)=("?)(.{9,}?)\2\](.+?)\[/\1\]][gi]{<a href="${match.3}">${match.4}</a>}]
          $sSmileOutput[^bbURL.match[(?<![="])((?i:https?://|ftp://|mailto:)(?:[:\w~%{}./?=&@,#-]+))][g]{<a href="$match.1" target="_blank">$match.1</a>}]
          $sSmileOutput