Regex testing: boundaries, flags and near misses
Revised 2026-10-09 · Synthetic examples
A useful pattern has both examples that should match and near misses that must not. This tester uses the browser’s JavaScript RegExp engine; another language may behave differently.
Test input and settings
Pattern: \bORD-\d{4}\b
Flags: g
Text: ORD-1042 ORD-0099 ORD-12345Open the tool and follow the steps belowStart with a falsifiable expectation
Enter the pattern without surrounding slash delimiters and put g in the separate flags field. Paste only the Text line into the text area. Expect ORD-1042 and ORD-0099, but not the first four digits of ORD-12345. Remove the final word boundary to reproduce that false positive.
Test the whole value when validating a field
Extraction and validation differ. For a field that must contain only one reference, use ^ORD-\d{4}$ without m and compare ORD-1042 with prefix ORD-1042 suffix. Test an empty value and extra line breaks as well. For strict application validation, also ensure the matched span equals the entire input; JavaScript $ can match before a final line terminator.
Keep format checks separate from meaning
A YYYY-MM-DD pattern can accept an impossible date. An email-shaped string may not belong to anyone. Use a calendar parser or a verification flow for those questions. This tester lists matches and captured groups; it does not prove application validity or worst-case performance. Invalid pattern syntax must be corrected before interpreting an empty match list.
Completion criteria and limits
Record positive and negative samples with expected counts. Avoid untrusted complex patterns on large inputs: backtracking can block the browser. A few fast samples are not a runtime bound.
Back to tasks and guides · Report an incorrect instruction or result