Results for “Strings & byte buffers”
Small, practical examples. Search by task or narrow things down below.
Split and trim text
Split simple comma-separated JavaScript text and trim each part.
JavaScript✓ Tested
Split and trim values
Split simple comma-separated C# text and trim each value.
C#✓ Tested
Split comma-separated text
Split a simple comma-separated string into individual Java values.
Java✓ Tested
Split comma-separated text
Use getline with a delimiter to split simple C++ text.
C++✓ Tested
Store a variable-length payload after a structure header
C: A flexible array member lets one allocation hold metadata and trailing bytes.
C✓ Tested
Test whether an array contains a value
PowerShell: The contains operator compares complete items rather than matching substrings.
PowerShell✓ Tested
Trim surrounding ASCII whitespace
C++: Find the first and last non-whitespace bytes before taking a substring.
C++✓ Tested
Trim surrounding whitespace
Remove whitespace at the ends of a C# string.
C#✓ Tested
Trim surrounding whitespace
Remove leading and trailing whitespace from a Java string.
Java✓ Tested
Trim surrounding whitespace
Remove leading and trailing JavaScript string whitespace.
JavaScript✓ Tested
Try parsing an integer
Use TryParse to avoid exceptions for invalid C# integer input.
C#✓ Tested
Validate a finite numeric value without coercion
JavaScript: Number.isFinite rejects numeric strings as well as NaN and infinity.
JavaScript✓ Tested