Results for “Strings & literal text”
Small, practical examples. Search by task or narrow things down below.
Convert known numeric text to an integer
C++: Convert a trusted literal to an integer before adding. Validate external input before converting it.
C++✓ Tested
Convert known numeric text to an integer
C: Convert a trusted literal to an integer before adding. Validate external input before converting it.
C✓ Tested
Copy text into a fixed buffer
Use snprintf and check for truncation when copying a C string.
C✓ Tested
Extract numbers from text
Find all runs of ASCII digits in a string and convert the matches to integers.
regex✓ Tested
Find a commit that changed the count of a text string
Git: The pickaxe -S option finds commits that add or remove occurrences of a literal string.
Git✓ Tested
Find text ignoring case
Use ordinal case-insensitive comparison for a C# substring search.
C#✓ Tested
Read a whole text file
Load text as one string instead of one item per line.
Get-Content✓ Tested
Read rows from CSV text
Parse CSV into objects with named properties.
CSV✓ Tested
Replace all literal matches
Replace repeated substrings with JavaScript replaceAll.
JavaScript✓ Tested
Replace text in a string
Replace every occurrence of a substring and keep the result in a new string. The original string is unchanged.
string✓ Tested
Search for text in a file
Find matching lines with their line numbers, ignoring letter case and treating the pattern as literal text.
grep✓ Tested
Set text safely
Use jQuery text to insert literal content instead of interpreting HTML.
jQuery✓ Tested