Page 1 of 1

Converting a string to string-array

Posted: Thu Jan 10, 2002 1:37 pm
by source1ben
How do you convert a string to a string-array ?

Example.

<$data = "'aaa' 'bbb' 'ccc' 'ddd' 'eee'">

Vortex recogizes this as a single entry array. I need it to have the values stored as an array - so I loop thru them.

Example.

<$data = 'aaa' 'bbb' 'ccc' 'ddd' 'eee'>

thx.

Converting a string to string-array

Posted: Thu Jan 10, 2002 1:51 pm
by Kai
The easiest way is with <rex> or <split>:

<rex "[^\space']+" $data>
<$data = $ret>

You may have to alter the expression depending on the possible character values for data vs. separator characters. If your values have complex or inconsistent quoting schemes, you may need to use something like <fmtcp sandcall> to handle special cases.

Converting a string to string-array

Posted: Thu Jan 10, 2002 2:06 pm
by source1ben
Works like a charm !

thx.