FIND YOUR NEXT FEW LINES

Results for “Strings & text”

Small, practical examples. Search by task or narrow things down below.

474 snippets foundClear filters
C++Strings

Reverse a string

Reverse a byte string in place with std::reverse.

C++✓ Tested
JavaPrecise numeric calculations

Round a decimal with an explicit rule

Java: Construct BigDecimal from text to avoid importing a binary floating-point approximation.

Java✓ Tested
PythonNumbers & calculations

Round decimal amounts explicitly

Python: Build Decimal values from strings and choose a rounding rule explicitly.

Python✓ Tested
PowerShellText & data

Serialize a hashtable as JSON

Produce compact JSON for a small data object.

JSON✓ Tested
JavaScriptObjects & JSON

Serialize an object

Turn a JavaScript object into JSON text.

JavaScript✓ Tested
C#Data & dates

Serialize an object to JSON

Serialize a small anonymous C# object with System.Text.Json.

C#✓ Tested
jQueryText & attributes

Set a form field value

Populate a labeled input with jQuery val.

jQuery✓ Tested
SQLiteJSON data

Set a JSON property

Create an updated JSON document from existing text.

json_set✓ Tested
jQueryText & attributes

Set an element attribute

Update an HTML link using jQuery attr.

jQuery✓ Tested
Linux CommandsText processing

Show the first lines of a file

Read only the first three lines of a text file, useful for checking a header or previewing a large log.

head✓ Tested
Linux CommandsText processing

Sort and deduplicate lines

Sort lines alphabetically and remove duplicate lines in a predictable C locale.

sort✓ Tested
Linux CommandsStreams & byte tools

Split a file into fixed line-count pieces

Linux Commands: Use numeric suffixes for predictable filenames when splitting a large text file.

Linux Commands✓ Tested