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