all groups > flash actionscript > december 2004 >
You're in the

flash actionscript

group:

Search string and Cut



Re: Search string and Cut David Stiller
12/31/2004 6:40:34 PM
flash actionscript: bocacio,

You can do all this with a few methods of the String class. Fire up
your ActionScript dictionary (F1 key) and look up "String class" for
details.

// Set original
var sbMsg = "Happy new year to all, santaclause is comming again";

// Set string2 to what you're looking for

// Use string2 to find the others
var string2 = "santaclause";
var string1 = sbMsg.substring(0, sbMsg.indexOf(string2));
var string3 = sbMsg.substring(sbMsg.indexOf(string2) + string2.length);

// Trace your strings
trace(string1);
trace(string2);
trace(string3);


David
stiller (at) quip (dot) net
"Luck is the residue of good design."

Search string and Cut bocacio
12/31/2004 11:31:20 PM
Hi, A HAPPY NEWYEAR TO ALL!!!!!

i have a string
sbMsg = "Happy new year to all, santaclause is comming again";
I want to search for santaclaus in that string and put all thats before
santaclaus (Happy new year to all, ) and everything after santaclaus ( is
comming again) in a new string. so, theres gonna be 3 new strings...
string1. Happy new year to all,
string2. santaclaus
string3. is comming again

i now there was somewhere a tutorial about this, but i cannot find it anymore.
If someone of you knows a tutorial about this..then that would be great...i
searched and googled all there is but cannot find what i need.

thanks
Re: Search string and Cut kglad
1/1/2005 12:17:34 AM
sbMsg = "Happy new year to all, santaclause is comming again";
searchString = "santaclause";
string1 = sbMsg.substring(0, sbMsg.indexOf(searchString));
string2 = sbMsg.substring(sbMsg.indexOf(searchString),
sbMsg.indexOf(searchString)+searchString.length);
string3 = sbMsg.substring(sbMsg.indexOf(searchString)+searchString.length);

p.s. i'm not sure why you'd use string2, but there it is.
Re: Search string and Cut bocacio
1/1/2005 12:45:36 AM
my god and i doing things much to complicated!! thanks for the quick answers
guys!!!

string 2 i want to use for replacement...so i want to attach something from
the library or load a jpg with the var in string 2....
so finally i got : string1(text) + string2 (attach something) + string3(text)
and attach this all to a new mc....




sorry for my poor english, but try :-)

thanks again
Re: Search string and Cut kglad
1/1/2005 12:51:06 AM
AddThis Social Bookmark Button