FIND YOUR NEXT FEW LINES

Results for “Strings & literal text”

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

495 snippets foundClear filters
Bash ScriptsVariables & text

Replace every occurrence in a string

Substitute text directly with Bash parameter expansion.

replace✓ Tested
PowerShellText & data

Replace repeated whitespace

Normalize runs of whitespace to one space.

regex✓ Tested
JavaRecords & reliable control flow

Represent a finite set of states

Java: Use an enum to prevent arbitrary strings from representing application states.

Java✓ Tested
CSSInteraction & themes

Reuse colors with custom properties

Define a CSS custom property and use it for text color.

CSS✓ Tested
C++Strings

Reverse a string

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

C++✓ Tested
C#Dates & precise numbers

Round a decimal using an explicit midpoint rule

C#: Use decimal literals for decimal arithmetic and choose the midpoint rounding behavior.

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
SQLGetting Started

Run a first SELECT query

SQL: Return a literal value without creating a table.

SQL✓ Tested
SQL ServerGetting Started

Run a first SELECT query

SQL Server: Return a literal value without creating a table.

SQL Server✓ Tested
PostgresGetting Started

Run a first SELECT query

Postgres: Return a literal value without creating a table.

Postgres✓ Tested
SQLiteGetting Started

Run a first SELECT query

SQLite: Return a literal value without creating a table.

SQLite✓ Tested