17 July 2011

AS3: Simple, Powerful String Find & Replace all instances function for Flash Actionscript. Similar to PHP's str_replace replacement.

Exactly what it says on the tin!

AS2 version here



Please see right hand pane before copying my code - thanks! >>

//needle and/or replacement can be either a string or an array of strings:
function replace ( needle, replacement, haystack:String):String{
   var r=haystack;
   if(typeof(needle)=="string"){
    needle = [needle]
   }
   if(typeof(replacement)=="string"){
    replacement = [replacement]
   }
   while(replacement.length<needle.length){
    replacement.push(replacement[replacement.length-1])
   }
   for(var i in needle){
    r = r.split(needle[i]).join(replacement[i])
   }
   return(r)
  }
//SAMPLE USAGE:
trace( replace( "A", "X", "ABCDEFG" ) )  //outputs: XBCDEF
trace( replace(["A","B","C"] , ["X","Y","Z"], "ABCDEFG") )  //outputs: XYZDEF

8 comments:

Juliana Kho said...


1
2 agen sabung ayam s128
3
4 honda black cbet
5 daftar kis918 indonesia
6 osg77 slot online
7
8 joker123 slot

JannethManalu said...
This comment has been removed by the author.
jasa website gembling said...

SEARCH ENGINE OPTIMIZATION SERVICES
JASA SEO INDONESIA
MARKETINGSEO.CO.ID
Kami menyediakan layanan berkualitas tinggi dari Pengoptimalan Mesin Telusur, Pembuatan Tautan, dan Pemasaran Konten. Ini termasuk:

• Analisis Kata Kunci & Strategi
• Optimasi Arsitektur Situs Web
• Code Optimization
• Strategi & Pengoptimalan Konten
• Penciptaan Infografis
• Conversion Rate Optimization
• Directory submission and optimization services
• Organic SEO results
• Landing page promotion
• Google Maps
• Local Newspaper and Communities


Master SEO indonesia (SEO) adalah proses memengaruhi visibilitas situs web atau halaman web dalam hasil mesin telusur — sering kali disebut sebagai hasil “alami”, “organik”, atau “earned”. Secara umum, yang lebih awal (atau peringkat lebih tinggi pada halaman hasil pencarian), dan lebih sering situs muncul dalam daftar hasil pencarian, semakin banyak pengunjung yang akan menerima dari pengguna mesin pencari, dan pengunjung ini dapat dikonversi menjadi pelanggan.

SeO indonesia dapat menargetkan berbagai jenis pencarian, termasuk pencarian gambar, pencarian lokal, pencarian video, pencarian akademik, pencarian berita dan mesin pencari vertikal khusus industri.
agen bola


poker online
poker uang asli


jasa seo indonesia



prediksi bola
jadwal bola
agen bola

yanmaneee said...

pandora
bape hoodie
pandora outlet
stephen curry shoes
golden goose
jordan 12
canada goose outlet
kobe byrant shoes
yeezy boost 350 v2
bape outlet

Susan said...

192.168.l.254.254 IP address is allocated by many brands to log in to the router management interface.

EASlot said...

Situs Slot Online Pulsa http://134.209.104.46/

Unknown said...

address 7a replica bags wholesale original site dolabuy louis vuitton over at this website replica louis vuitton bags

Unknown said...

v1n37e8r95 q8i58e5w92 q7x46m4i78 x4e45g1e67 l2t03n0z18 i2m93j8y39

Post a Comment

Cron Design Studio: Dublin based web design & software development