strstrip
Prev | Orchestra Opcodes and Operators | Next

## strstrip

strstrip — Strip whitespace from string

## Description

Plugin opcode in emugens.

Strip whitespace from string. Whitespace can be removed from left, right or both sides. Works at init-time.

## Syntax

    Sout strstrip Sin [, Smode]

## Initialization

Sin -- Input string

Smode -- If not given, whitespace is stripped from both sides. If "l", strip whitespace from left side. If "r", strip whitespace from right side.

## Examples

Here is an example of the strstrip opcode. It uses the file strstrip.csd.

Example 1052. Example of the strstrip opcode.

    <CsoundSynthesizer>
    <CsOptions>
    --nosound

    </CsOptions>

    <CsInstruments>

    /* strstrip: strip whitespace from string

     Sout strstrip Sin [, Smode]

     Args
       Sin - string to strip whitespace from
       Smode - if not given, whitespace is stripped from left and right edges
               "l" - strip whitespace from left edge only
               "r" - strip whitespace from right edge only
     */

    instr 1
      Sout = strstrip("  \t\n  foo bar   \t\n")
      ; Sout = strstrip("  center   ", "l")
      ; Sout = strstrip("  center   ", "r")

      prints "string: '%s'\n", Sout
      turnoff
    endin

    </CsInstruments>

    <CsScore>

    i1 0 1

    </CsScore>
    </CsoundSynthesizer>

## See Also

String Manipulation Opcodes

## Credits

By: Eduardo Moguillansky 2020

Prev | Up | Next
strset | Home | strsub