function | The trick function is as follows:
Remove notes and trailing spaces, www.fanflash.cn
Private Function DeleteComment (dt:string): string{
var mark:string= "'"
var newstr:string;
Remove annotations
var markid:number=dt.lastindexof (mark,dt.length);
if (markid==-1) {
NEWSTR=DT; No comment
}else{
Newstr=dt.slice (0,markid); Have comments
}
Remove spaces
var len:number=newstr.length;
var Deleteid:number=len//position with no white space characters
for (Var i=len-1;i>=0;i--) {
if (Newstr.charat (i)!= "") {
Deleteid=i;
Break Jump out of the loop
}
}
Return Newstr.slice (0,deleteid+1);
Example
For example, the name of a STRING,STR is AA:
----------------------------------------------------------------------------------
http://localhost/videoboard/saveimage/' Save the address of the picture folder
http://localhost/videobard/aspx/' script file file parity address
------------------------------------------------------------------------------------
You can use the above function in this way:
Private Function Analyzestext (dt:string) {
var txtarr:array=dt.split ("\ n");
var len:number=txtarr.length
for (Var i=0;i<len;i++) {
Trace (This.deletecomment (txtarr[i]));
}
And then execute this. Analyzestext (AA), you can output each line of the corresponding no comment no trailing space of STR
What is this function for?
I am writing a program configuration file, with XML too cumbersome, data redundancy is too large, the simplest is the configuration of the variable written in a row, but also afraid that others can not understand the meaning of this row variable, so add a comment after the variable, but to the program inside the annotation must be removed, so there is the above function.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.