Christine_Chavez_6412

STR_SPLIT in version 11 handles 'spaces' or multiple separators differently than version 10 and 9

Discussion created by Christine_Chavez_6412 on May 20, 2016
Latest reply on May 21, 2016 by Michael_Lowry

In version 11, 'Spaces' are not trimmed when you use STR_SPLIT.
Having multiple separators also are handled differently wherein if you have a string of
"A(space)(space)B(space)(space)C" and use STR_SPLIT to fill an array, you'll end up with an array of:

&STRING# = "A  B C"
FILL &ARRAY#[]=STR_SPLIT(&STRING#,' ') 
&ARRAY#[1] = A
&ARRAY#[2] = 
&ARRAY#[3] = B
&ARRAY#[4] = 
&ARRAY#[5] = C


In Version 9 or 10, you'll get the following result: 
&ARRAY#[1] = A
&ARRAY#[2] = B
&ARRAY#[3] = C

Note:This applies for other multiple separators as well, not just 'spaces'
Example: &STRING# = A. . . B. . . . . C. . .


One workaround that you can try is to either use LTRIM or RTRIM  
:SET &MY_VAR#  = LTRIM(&ARRAY#[1])
or 
:set &FOUND# = 'Y' 
:while &FOUND# = 'Y' 
: set &STRING# = str_substitute(&STRING#," "," ") !!!----- this will replace TWO spaces with ONE space ----!!! 
: set &hasDUP# = str_find(&STRING#," ") !!!----- note that I am using TWO spaces here ----!!! 
: if &hasDUP# = 0 
:     set &FOUND# = 'N' 
: endif 
:endwhile 
 
:FILL &ARRAY#[]=STR_SPLIT(&STRING#,' ') 



This bug has been fixed in the following version (not yet released):

Automation.Engine 12.0.0
Automation.Engine 10.0.8
Automation.Engine 11.1.3
Automation.Engine 11.2.2 

Outcomes