How split a document

Hi,
I have a script that retrieves the content of another document. I want to split this content with “;”. I was looking for the possibility to use “split”, but nowhere in the documentation I see such a possibility

{{velocity}}
#set ($newDoc = $xwiki.getDocument('MyDoc1.WebHome'))
#set doc1 = $newDoc.getContent()

#set($myList = [])
**here I want split my doc1 and add extracted content to the myList**

$myList
{{/velocity}}

Hi, you can simply write the for-each statement and store each iteration value (string) into an array. Please, note that [] is mandatory for the split method.

#foreach($element in $doc1.split("[;]"))
  #set ($discard = $myList.add($element))
#end

It’s works :slight_smile: thank You

I’ve another question. when I use $myList.add($element) in my document content “true” is added. What can I do if I don’t want to show the “true” ?

I’ve updated the post with solution.