The String module provides comprehensive string manipulation capabilities for Soul, offering methods for case conversion, trimming, padding, searching, replacement, validation, and transformation. It follows a JavaScript-like API for familiar string operations.
Unicode awareness: String operations are Unicode-aware for proper character handling
Null safety: Methods return null for invalid inputs
Immutability: String methods return new strings, leaving originals unchanged
Performance: Use appropriate methods for your use case
Validation: Always validate string inputs before processing
Copy
Ask AI
// Good - check for empty stringssoul safeStringOperation(text) { if (String.isEmpty(text)) { return "" } return String.toUpperCase(String.trim(text))}// Good - chain operations for readabilityresult = String.trim(input) |> String.toLowerCase() |> String.toCamelCase() |> String.padCenter(20, "*")// Good - use appropriate validationsoul validateEmail(email) { if (String.isEmpty(email)) { return false } return String.contains(email, "@") && String.contains(email, ".")}// Good - handle Unicode properlytext = "café"chars = String.toCharArray(text) // Properly handles Unicodelength = String.length(text) // Returns 4, not 5
The String module provides comprehensive tools for string manipulation in Soul, enabling powerful text processing capabilities with a familiar and intuitive API.