Results for “regex”
Small, practical examples. Search by task or narrow things down below.
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
Check whether input is a nonnegative integer
Reject empty input and nonnumeric characters before arithmetic.
validation✓ Tested
Extract all integer tokens from text
C#: Enumerate Match objects returned by Regex.Matches with an explicit timeout.
C#✓ Tested
Extract digit sequences
Extract digit sequences using a complete Go program with explicit sample inputs.
Go✓ Tested
Extract numbers from text
Find all runs of ASCII digits in a string and convert the matches to integers.
regex✓ Tested
Iterate over all regular-expression matches
C++: A regex iterator yields successive matches without manually updating an offset.
C++✓ Tested
Read fields captured by a Bash regular expression
Bash Scripts: BASH_REMATCH contains the full match followed by capture groups after a successful regex test.
Bash Scripts✓ Tested
Replace all matching text
Normalize repeated whitespace with a regular expression.
regexp_replace✓ Tested
Replace repeated whitespace
Normalize runs of whitespace to one space.
regex✓ Tested
Split text on several separator characters
JavaScript: A regex character class can recognize alternative simple delimiters.
JavaScript✓ Tested
Split text on several separator characters
TypeScript: A regex character class can recognize alternative simple delimiters.
TypeScript✓ Tested
Use a literal value in a regular expression
PowerShell: Regex.Escape prevents a literal dot or other metacharacter from changing the match.
PowerShell✓ Tested