3ds Max 8 以降では、キーワード パラメータ splitEmptyTokens: が filterString 関数に渡され、この種類のフィルタリングが実行されます。
filterString 関数は、空のエントリを返しません。たとえば、1行に 2 つのタブを含んだ文字列を、タブを使用してフィルタリングする場合、空のエントリは返されません。
例:
filterString "One\\t\\tThree Four,,Five ""\\t, "
#("One", "Three", "Four", "Five")
次のスクリプト関数で目的の処理を行えます。
スクリプト関数:
fn filterString2 theString theDelimiters = ( theTokens = #() --array of tokens to return ready = false while not ready do --repeat until no more delimiters can be found ( ready = true --raise a flag that we are done thePosArray = #() --init. an array to hold possible split positions for i = 1 to theDelimiters.count do --go through all delimiters ( checkPos = findString theString theDelimiters[i] --check if the delimiter is in the string if checkPos != undefined do append thePosArray checkPos --if it is, add to the split positions array ) --end i loop if thePosArray.count > 0 then --if the array has any splitpositions, ( sort thePosArray --sort the array in ascending order checkPos = thePosArray[1] --grab the first position aToken = substring theString 1 (checkPos-1) --take the token from start to the split pos. - 1 append theTokens aToken --add the token to the array of tokens theString = substring theString (checkPos+1) theString.count --remove the token and the delimiter from the string ready = false --lower the flag because we are not ready yet ) --end if ) --end while loop append theTokens theString --add what is left of the string to the array theTokens --return the array of tokens )
filterString2 "One\t\tThree,Four,,Five " "\t," #("One", "", "Three", "Four", "", "Five ")
filterString2 "One\t\tThree Four,,Five " "\t, " #("One", "", "Three", "Four", "", "Five", "")