xinranok
 
 
 
 
 

xidelongok 最新的 20 条日志

 
 
Splitting strings [2006-1-28]
xidelongok 发表在 学习笔记
方法1-------------
on stringToList thisString
-- store the current itemDelimiter...
oldDelim = the itemDelimiter
-- set a new itemDelimiter...
the itemDelimiter = "."
-- create a new empty list...
tempList = []
-- find out how many items are in the string to be parsed...
thisManyItems = thisString.item.count
-- loop through each item...
repeat with n = 1 to thisManyItems
-- put each item into a local variable...
tempString = thisString.item[n]
-- remove the last charactor, the "."...
delete tempString.char[tempString.char.count]
-- add that string to the list...
tempList.add(tempString)
end repeat
-- restore the itemDelimiter...
the itemDelimiter = oldDelim
-- return the list of strings to the calling function...
return tempList
end
=====================
2.-------------------
The itemdelimiter = "."
str = "This is your string. With the different sentences. see."
strlist = []
repeat with i=1 to str.item.count
strlist.add(str.item[i])
end repeat
put strlist
--------------
3.-------------
function split(aString, aChar){

return aString.split(aChar);

}

An example from the Message window:
p = "This is a test. This is another test. Test three."
a = split(p, ".")
put a[0]
-- "This is a test"
put a[1]
-- " This is another test"


≡≡≡≡≡ 评论(共 条)我要评论
 
Power by 5D Design by wolfprince