Command: breakup

NEST HelpDesk Command Index NEST Quick Reference

Name:
 breakup - Break a string or an array at given Substrings or SubArrays, or to given lengths.
   
Synopsis:
 MyStr BreakStr breakup -> StrArr
             MyArr BreakArr breakup -> ArrArr
             MyStr SecLen   breakup -> StrArr
             MyArr SecLen   breakup -> ArrArr

Description:
 Break a string or an array at given Substrings or SubArrays, or to sections
                of given length. In the latter case, the last section may be shorter, if
                the section length does not evenly divide the string/array length.

Parameters:
 In : MyStr(string)/MyArr(array): String/Array to break up.
                    BreakStr(string)/BreakArr(array): Substring/Subarray defining break points.
                    SecLen(int): Length of sections to form
               Out: StrArr(array of strings)/ArrArr(array of arrays): array of partial strings/arrays (see example below)

Examples:
 1. (home/kupper/synod) (/) breakup -> [(home) (kupper) (synod)]
             2. (Theresnospaceinhere) ( ) breakup -> [(Theresnospaceinhere)]
             3. [23 5 0 17 0] [0]   breakup -> [ [23 5] [17] [] ]
             4. [23 5 0 17 0] [5 0] breakup -> [ [23] [17 0] ]
             5. (abcdef) 3 breakup -> [(abc) (def)]
             6. (abcdef) 4 breakup -> [(abcd) (ef)]
             7  [1 2 3 4] 2 breakup -> [[1 2] [3 4]]

Bugs:
 

Author:
 R Kupper, H E Plesser

FirstVersion:
 Apr 10 1999

Remarks:
 Inspired by IDL's STRBREAK-function

   Procedure: Recursive call of "search"

SeeAlso:trim
Source:
 /home/abuild/rpmbuild/BUILD/nest-2.4.1/lib/sli/misc_helpers.sli

NEST HelpDesk Command Index NEST Quick Reference

© 2000-2010 The NEST Initiative