Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
regex vs includes - case insensitive
(version: 0)
Comparing performance of:
regex vs includes
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
var string = "Hello world!"; var regex = /hello/i; var search = "hello";
Tests:
regex
regex.test(string);
includes
string.toUpperCase().includes(search.toUpperCase());
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
regex
includes
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:136.0) Gecko/20100101 Firefox/136.0
Browser/OS:
Firefox 136 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
regex
56393596.0 Ops/sec
includes
2834428672.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
**Benchmark Overview** The provided JSON represents a JavaScript benchmark on MeasureThat.net, which compares the performance of regular expressions (regex) and the `includes` method in case-insensitive searches. **Tested Options** There are two test cases: 1. **Regex**: The first test case uses a regular expression (`/hello/i;`) to search for the string "hello" (case-insensitive). 2. **Includes**: The second test case uses the `toUpperCase()` method followed by the `includes()` method to search for the uppercase version of the string "hello". **Pros and Cons** * **Regex:** + Pros: - Can be used for complex pattern matching. - Provides more control over the search process. + Cons: - Can be slower due to the complexity of the pattern. - May require additional processing steps (e.g., escaping special characters). * **Includes:** + Pros: - Generally faster than regex for simple string matching. - More concise and readable code. + Cons: - Limited control over the search process. - Requires the `toUpperCase()` method, which can introduce additional processing steps. **Library Usage** In this benchmark, no libraries are explicitly mentioned. However, the `includes` method is a built-in JavaScript method that is widely supported across browsers and platforms. **Special JS Features or Syntax** This benchmark uses: * **Case-insensitive search**: The `/hello/i;` regex pattern and the `.toUpperCase()` method with `includes()` use case-insensitive searching. * **Browser-specific details**: The provided JSON includes information about the browser (Chrome 123) and device platform (Desktop), which can affect performance. **Other Alternatives** If you wanted to test alternative approaches, you could consider adding additional test cases for: * **String manipulation libraries**: Using a library like Lodash or Underscore.js to perform string matching. * **Regular expression alternatives**: Testing the `startsWith()` and `endsWith()` methods instead of regex. * **Other search algorithms**: Exploring more complex algorithms, such as Boyer-Moore or Knuth-Morris-Pratt. These alternative approaches could provide additional insights into performance differences between various techniques.
Related benchmarks:
RegEx.test vs. String.includes case insensitive
Case insensitive RegEx.test vs. String.includes when string doesn’t match
RegEx.test vs. String.includes incasesensitive
Case Insensitive RegEx.test vs. String.includes
Comments
Confirm delete:
Do you really want to delete benchmark?