Jump to content
Sign in to follow this  


Recommended Posts


I had to split a list using a char before and a char just after.

So I made this UDF, hoping that is useful to someone I'll post it here.

Example of a list that need DoubleSplit:


Having an array with names and an array with values is very easy with DoubleSplit:

$l = 'name=value;name2=value2;name3=value3'
$l = _DoubleSplit($l,';','=')
$l = StringSplit($l,@cr)

$names = StringSplit($l[1],@lf)
$values = StringSplit($l[2],@lf)

Func _DoubleSplit($LIST, $FCHAR, $SCHAR)
   Local $C, $STR, $FLIST, $SLIST
   $STR = StringSplit($LIST, $FCHAR)
   For $C = 1 To $STR[0]
      $FLIST = StringTrimLeft($STR[$C], StringInStr($STR[$C], $SCHAR)) & @LF & $FLIST
      $SLIST = StringLeft($STR[$C], StringInStr($STR[$C], $SCHAR) - 1) & @LF & $SLIST
   $FLIST = StringTrimRight($FLIST, 1)
   $SLIST = StringTrimRight($SLIST, 1)
   Return $SLIST & @CR & $FLIST
EndFunc  ;==>_DoubleSplit
Edited by ezzetabi

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this