-
Client Software Programmer
Really good way to escape all characters you want:
I found out a way to make a really good escape so here it is..
event.data.substr(event.data.indexOf(event.data.sp lit(";")[2]),event.data.length).substr(0,event.data.substr(ev ent.data.indexOf(event.data.split(";")[2]),event.data.length).length-1)
flashkit added some spaces so watch out ^
event.data being: "chat;username;blahreageagrea;#@$@:;f;eweoag;greag rea;g;re;g;fdg;fd;g;re;t;e;r:@!:#$@!:R$;"
Last edited by AS3.0; 11-11-2016 at 06:03 PM.
-
.
Hi,
It just looks like a very convoluted way of splitting some data Alloy.
Not sure how you are passing it over or whatever.
If its just a case of splitting the data using the ";" as the delimiter then you could simply use a reg exp or a simple split.
var theData:String = "chat;username;blahreageagrea;#@$@:;f;eweoag;greag rea;g;re;g;fdg;fd;g;re;t;e;r:@!:#$@!:R$;";
var thePattern:RegExp = /;/g;
var splitData:Array = theData.split(";");
//var splitData:String = theData.replace(thePattern, "\n");
trace(splitData);
-
Client Software Programmer
Hi, my code uses ; as a delimeter to skip through to the string i want and the rest can still have ";"
your code gets everything between the ";" leaving ; out on areas needed
-
Client Software Programmer
this ways even better if i want to skip semicolon tell me if you have a better way fruitbeard
var mystr="hey;hey;hey;hey;"
var count=0;
var tempstr=mystr
var colAt:Number=0;
for(var i=0;i<mystr.length;i++){
tempstr=tempstr.substr(1,tempstr.length);
if(mystr.charAt(i)==";"){
colAt++;
}
if(colAt==2){
trace(tempstr.substr(0,tempstr.length-1));
break;
}
}
-
.
Hi,
I'm not sure what you are trying to do Alloy.
All that does is trace "hey;hey"
nor with twe first one come to that, perhaps you should illustrate yourself a little better with what it is you wish to achieve and add more code, how are you getting your data, would it not be easier to just import any data in an array in the first place etc etc
also, why use a delimiter that is used for more than one thing, makes things a lot harder, try using a unique delimiter
Last edited by fruitbeard; 11-13-2016 at 05:21 AM.
-
.
Hi,
Not sure if this is what you require?
var mystr:String = "hey;hey;hey;hey;";
var tempstr:String;
if (mystr.indexOf(';') != -1)
{
tempstr = mystr.replace(";"," : ");
trace(tempstr);
}
-
Client Software Programmer
Hi, I am yet to use replace, I will try that thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|