Results for “Text validation & formatting”
Small, practical examples. Search by task or narrow things down below.
Build text efficiently in a loop
Java: Append to StringBuilder when constructing a string incrementally.
Java✓ Tested
Extract text between known positions
Java: Java substring uses a start-inclusive, end-exclusive range of UTF-16 indices.
Java✓ Tested
Repeat text a fixed number of times
Java: Use String.repeat with a nonnegative repetition count.
Java✓ Tested
Treat dynamic regex input as literal text
Java: Use Pattern.quote so metacharacters in a search term lose their special meaning.
Java✓ Tested
Check a filename suffix
Java: Use endsWith for a case-sensitive literal suffix test.
Java✓ Tested
Check a string prefix
Java: Use startsWith to check a literal Java prefix without a regular expression.
Java✓ Tested
Count Unicode code points
Java: Use codePointCount when supplementary characters should count as one rather than two UTF-16 units.
Java✓ Tested
Extract successive regex matches
Java: Use a Matcher loop to find all unsigned integer tokens in Java text.
Java✓ Tested
Process the lines of an in-memory string
Java: Use String.lines to handle common line terminators without retaining them.
Java✓ Tested
Validate a complete identifier
Java: String.matches requires the regular expression to match the entire input.
Java✓ Tested
Convert text without raising a conversion error
Return NULL when a numeric conversion fails.
TRY_CONVERT✓ Tested
Build text incrementally with StringBuilder
C#: Append fragments instead of repeatedly concatenating intermediate strings in a loop.
C#✓ Tested