Notifications
Clear all

[Closed] String Parsing Help

I am having a hard time finding a good way to parse a string and store it in an array… here is an example:

I parsed this from a file:

(320 -192 448) (0 -192 448) (0 -192 0)"

the original string of text in the file looked like this:

"id1" "(320 -192 448) (0 -192 448) (0 -192 0)"

I would like to have that string end up in an array like this:

#([320,-192,448],[0,-192,448],[0,-192,0])

any help would be greatly appreciated

Thanks
-Baker

4 Replies

Hi Jonathan,

I think that the best solution is to use filterString method in string class like this :

parsedLine = "(320 -192 448) (0 -192 448) (0 -192 0)"
filteredLine = filterString parsedLine "() "

pointArray = #()
for i = 1 to filteredLine.count by 3 do
(
	point = Point3 (filteredLine[i] as float) (filteredLine[i+1] as float) (filteredLine[i+2] as float)
	append pointArray point
)

print pointArray

WOW thanks alot where did you find this?

Thanks again
-Baker

Hi Jonathan,

It’s my own code. I’ve coded it for you :).

Moreover filterString is a very handy method when parsing strings.

thank you very much I am very appreciative … not much else to say except thanks alot I need the help

-Baker