x-ƒ (x_f)

Atkal stringi :) 

svētdien, 20.03.2005 @2:10 pm | x-ƒ

Divas string funkcijas, kas jums varētu noderēt. Pārpublicētas no [info]s2layers kopienas ieraksta "bunches of string functions". Ja kādu dikti interesē, tur ir vēl dažas.

replace_text(string text, string find, string replacement) : string
 "Search within \$text and replaces any occurences of \$find with \$replacement."

[info]mageboltrat's Saiteindustrial nippon
function replace_text(string text, string find, string replacement) : string
"Search within \$text and replaces any occurences of \$find with \$replacement." { ####################################################### # from lj:mageboltrat's industrial nippon (id=533012) # ####################################################### var string[] findarray; var int pos = 1; foreach var string findcharacter($find) { $findarray[$pos] = $findcharacter; $pos = $pos + 1; } var int place = 1; var bool found = false; var string completedtext = ""; var string foundtext = ""; foreach var string searchcharacter($text) { if ($searchcharacter == $findarray[$place]) { if ($place == $find->length()) { $foundtext = $replacement; $place = 1; } else { $foundtext = $foundtext + $searchcharacter; $place = $place + 1; } } else { $completedtext = $completedtext + $foundtext + $searchcharacter; $foundtext = ""; $place = 1; } } $completedtext = $completedtext + $foundtext; return $completedtext; }
example:
var string replaced_text = replace_text(
               $e.text,
               "http://stat.livejournal.com/img/userinfo.gif",
               "http://pics.livejournal.com/img/fb-userinfo.gif"
               );
------------------------------------

rehtml(string text) : string
 "Unescape html in \$text by replacing &gt; with > and &lt; with <."

developed by [info]masterslacker using [info]mageboltrat's replace_text
function rehtml(string text) : string
"Unescape html in \$text by replacing &gt; with > and &lt; with <." { #################################################################### # by lj:masterslacker using lj:mageboltrat's replace_text function # #################################################################### return replace_text(replace_text($text, "&lt;", "<"), "&gt;", ">"); }
example: if html is entered into the customization wizard it is stored inside the property in its escaped form. this function will unescape it.

(Ņem vērā, ka parasti neviens neizvēlas atbildēt uz pilnīgi anonīmiem komentāriem!)

No:
Lietotājvārds:
Parole:
Ievadi te 'qws' (liidzeklis pret spambotiem):
Temats:
Tematā HTML ir aizliegts
  
Ziņa:

Gandrīz jau aizmirsu pateikt – šis lietotājs ir ieslēdzis IP adrešu noglabāšanu. Operatore Nr. 65.