Hi All, I want to split the string using DXL. String variable contains lot of ';' character. I want to split the string using delimiter ; for example - string s = "this;string;shall;split"; I want to get output in the string array, where array shall store 'this', 'string', 'shall', 'split' string values in it. I have been searching to split the string using dxl and found the below links 2) http://stackoverflow.com/questions/1043604/string-split-in-dxl
Thanks in advance Prashant Prashant7 - Sat Nov 05 01:46:08 EDT 2016 |
Re: Split the string using DXL with delimiter as ; If you look in the dxl help file under regular expressions examples you will find an example that can be tailored to do as you requested. |
Re: Split the string using DXL with delimiter as ; Skip seems better than array to store the result ... you can try the following code ... Skip split ( string s, char c ) { Skip split_string = create(); int deb = 0; int i; int index = 0; for ( i=0; i<length(s)-1; i++ ) { if ( s[i] != c ) continue; put( split_string, index, s[deb:i-1] ); deb = i+1; index += 1; } if ( s[i] == c ) i--; put( split_string, index, s[deb:i] ); return(split_string); } Skip split ( string s, string sep ) { Skip split_string = create(); Buffer b = create() int deb = 0 int fin = keyword( b, sep, deb ) int index = 0 while (fin != -1) { put( split_string, index, s[deb:fin+length(sep)] ) deb = fin+length(sep)+1 fin = keyword(b, sep, deb) } delete b put( split_string, index + 1, s[deb:] ) return split_string } have fun ;) |