Regex Comparison: Word Boundary vs No Boundary

Benchmark created on


Description

Compare \b[Dd]isadvantageously\b (with word boundaries) vs [Dd]isadvantageously (without boundaries).

Test runner

Ready to run.

Testing in
TestOps/sec
With word boundaries
// Test Case 1: With word boundaries (\b)
const testWithBoundary = () => {
  const regex = /\b[Dd]isadvantageously\b/;
  return regex.test("Disadvantageously") && !regex.test("DisadvantageouslyX");
};
ready
Without word boundaries
// Test Case 2: Without word boundaries
const testWithoutBoundary = () => {
  const regex = /[Dd]isadvantageously/;
  return regex.test("Disadvantageously") && regex.test("XDisadvantageouslyY");
};
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.