FIND YOUR NEXT FEW LINES

Results for “Text validation & parsing”

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

547 snippets foundClear filters
PythonText validation & encoding

Remove a known suffix safely

Python: Use removesuffix to remove only a matching ending.

Python✓ Tested
Bash ScriptsText parsing & arithmetic

Remove a trailing carriage return from a line

Bash Scripts: Use an ANSI-C quoted carriage return as the suffix pattern.

Bash Scripts✓ Tested
Bash ScriptsText parsing & arithmetic

Set and clear a bit in a shell integer

Bash Scripts: Use shifts and bitwise operators for a small flag field.

Bash Scripts✓ Tested
Bash ScriptsText parsing & arithmetic

Split a record while retaining its remainder

Bash Scripts: The final read variable receives the remainder of a delimited record.

Bash Scripts✓ Tested
Bash ScriptsText parsing & arithmetic

Test numeric divisibility with a remainder

Bash Scripts: The modulo operator computes an integer remainder.

Bash Scripts✓ Tested
JavaText validation & formatting

Validate a complete identifier

Java: String.matches requires the regular expression to match the entire input.

Java✓ Tested
C#Text validation & encoding

Validate a complete identifier with a regex

C#: Use absolute anchors and a timeout so the regex checks the complete input with a bounded execution time.

C#✓ Tested
PythonText validation & encoding

Validate an entire identifier

Python: Use fullmatch so a regex must consume the complete input.

Python✓ Tested
PowerShellStructured formats & encodings

Convert between hexadecimal text and bytes

PowerShell: Use the .NET hexadecimal helpers instead of parsing byte pairs manually.

PowerShell✓ Tested
HTMLInput constraints

Limit typed text to a maximum length

HTML: Maxlength limits ordinary user editing without replacing server-side validation.

HTML✓ Tested
CNumbers & memory

Parse an integer with validation

Validate range and trailing characters when parsing a C integer with strtol.

C✓ Tested
HTMLInput constraints

Require a nonempty text value

HTML: The required attribute makes an empty text control fail native constraint validation.

HTML✓ Tested