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 1039. 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

strcat, strsub

Credits

By: Eduardo Moguillansky 2020