FIND YOUR NEXT FEW LINES

Results for “Text validation & encoding”

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

545 snippets foundClear filters
TypeScriptRegular expressions & URL encoding

Split text on several separator characters

TypeScript: A regex character class can recognize alternative simple delimiters.

TypeScript✓ Tested
JavaText validation & formatting

Treat dynamic regex input as literal text

Java: Use Pattern.quote so metacharacters in a search term lose their special meaning.

Java✓ Tested
GoErrors & validation

Wrap an error with context

Wrap an error with context using a complete Go program with explicit sample inputs.

Go✓ Tested
JavaText validation & formatting

Check a filename suffix

Java: Use endsWith for a case-sensitive literal suffix test.

Java✓ Tested
C++Text validation & parsing

Check a literal prefix in C++17

C++: Use string compare because starts_with was introduced after C++17.

C++✓ Tested
C++Text validation & parsing

Check a literal suffix in C++17

C++: Check lengths before subtracting to avoid an unsigned underflow.

C++✓ Tested
JavaText validation & formatting

Check a string prefix

Java: Use startsWith to check a literal Java prefix without a regular expression.

Java✓ Tested
JavaText validation & formatting

Count Unicode code points

Java: Use codePointCount when supplementary characters should count as one rather than two UTF-16 units.

Java✓ Tested
C++Text validation & parsing

Extract a substring with an explicit count

C++: The second substr argument is a length rather than an ending index.

C++✓ Tested
JavaText validation & formatting

Extract successive regex matches

Java: Use a Matcher loop to find all unsigned integer tokens in Java text.

Java✓ Tested
C++Text validation & parsing

Inspect a substring without allocating a copy

C++: A string_view refers to existing storage and must not outlive that storage.

C++✓ Tested
C++Text validation & parsing

Iterate over all regular-expression matches

C++: A regex iterator yields successive matches without manually updating an offset.

C++✓ Tested