next | previous | forward | backward | up | top | index | toc | Macaulay2 web site
Macaulay2Doc > The Macaulay2 language > strings and nets > separate

separate -- split a string into pieces

Description

Synopsis

  • Usage:
    separate s
  • Inputs:
  • Outputs:
    • an array of strings obtained from the string s by breaking it into lines

Synopsis

  • Usage:
    separate(nl,s)
  • Inputs:
  • Outputs:
    • an array of strings obtained from the string s by breaking it at the characters specified by the string nl

The value is a list of the pieces, the number of which is one more than the number of occurrences of d in s, so that the pieces may be reassembled with demark to get the original string.

An exception to what was just said is that the form separate s is designed to break lines correctly when the file follows either the Unix or MS-DOS convention. In other words, it will break a line at "\r\n" or "\n", and thus reassembly with demark may not give the original string.

i1 : separate( ".", "a.b.c.d" )

o1 = {a, b, c, d}

o1 : List
i2 : peek oo

o2 = {"a", "b", "c", "d"}
i3 : demark("=",ooo)

o3 = a=b=c=d
i4 : separate( "a\nb\nc\n" )

o4 = {a, b, c, }

o4 : List
i5 : peek oo

o5 = {"a", "b", "c", ""}

See also

Ways to use separate :