Results for “Text handling & Unicode”
Small, practical examples. Search by task or narrow things down below.
Read named fields from a successful regex match
PowerShell: The Matches table is updated after a successful scalar match operation.
PowerShell✓ Tested
Read the kind of command being invoked
PowerShell: CommandType distinguishes cmdlets from functions, aliases, and external applications.
PowerShell✓ Tested
Reject an integer with trailing characters
Arduino / C: strtol exposes an end pointer so a parser can require the entire token.
Arduino / C✓ Tested
Remove a known prefix safely
Python: Use removeprefix instead of lstrip when removing a literal prefix rather than a set of characters.
Python✓ Tested
Remove a known suffix safely
Python: Use removesuffix to remove only a matching ending.
Python✓ Tested
Remove a prefix only when it matches
Remove a prefix only when it matches in a complete Rust program using the standard library.
Rust✓ Tested
Remove a trailing carriage return from a line
Bash Scripts: Use an ANSI-C quoted carriage return as the suffix pattern.
Bash Scripts✓ Tested
Remove an optional prefix
Remove an optional prefix using a complete Go program with explicit sample inputs.
Go✓ Tested
Remove blank or whitespace-only lines
Linux Commands: Use a POSIX character class so tabs and spaces are handled together.
Linux Commands✓ Tested
Remove carriage-return characters
Linux Commands: Use tr -d to remove CR characters from Windows-style line endings.
Linux Commands✓ Tested
Reorder fields with a capture group
Linux Commands: Use extended regular expressions and backreferences to rearrange a known format.
Linux Commands✓ Tested
Replace a literal substring
SQL: REPLACE performs a literal replacement rather than a regular-expression substitution.
SQL✓ Tested