Skip to main content

string

Strings in Soul represent sequences of characters enclosed in quotes. They support various operations for text manipulation, searching, and formatting.

Basic String Literals

Create strings using single or double quotes:

String Concatenation

Combine strings using the + operator:

String with Variables

Include variables in strings:

String Escaping

Use escape characters for special characters:

String Methods

Common string operations:

String Searching

Find substrings and characters:

String Replacement

Replace parts of strings:

String Splitting

Split strings into arrays:

String Slicing

Extract portions of strings:

String Comparison

Compare strings:

String Formatting

Format strings with data:

String Validation

Validate string content:

String Manipulation

Advanced string operations:

String Joining

Join arrays into strings:

String Patterns

Common string patterns:

String Interpolation

Simple string interpolation:

String Encoding

Handle string encoding:

String Utilities

Utility functions for strings:

Best Practices

  1. Use appropriate quotes: Choose single or double quotes consistently
  2. Escape special characters: Handle quotes and backslashes properly
  3. Validate input: Check for null and empty strings
  4. Use string methods: Leverage built-in string operations
  5. Handle Unicode: Be aware of character encoding issues
Strings are fundamental to most Soul applications. Use them effectively with proper validation, manipulation, and formatting to create robust text processing functionality.