SplitScript reference / String / replaceAll

String.replaceAll

Method

String.replaceAll(search: String, replacement: String) -> String!

Replaces every exact, non-overlapping occurrence of a string.

Matches are case-sensitive and selected from left to right. An empty search string returns an error because insertion between bytes would not preserve the UTF-8 string invariant. The result is allocated at its exact final byte length; an unrepresentable length also returns an error.

Parameters

  • search: The non-empty string to find.
  • replacement: The string inserted for every match.

Effects: allocates

Runtime behavior: available everywhere; synchronous

Examples

Normalize a scene-name separator

let sceneName = "Forest_Complete"
let label = sceneName.replaceAll("_", " ") else sceneName