Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Pruebaaaaaaaaaaaaaaaaaaaaaaaa
(version: 0)
Comparing performance of:
For vs Regex
Created:
3 years ago
by:
Guest
Jump to the latest result
Tests:
For
function getInputVariables(text) { const arrayInputs = []; if (text && 0 < text.length) { const arrayText = text.split(""); let isInput = false; let input=""; arrayText.forEach(function(letter) { if (letter!="%" || isInput) { if (letter==="%" && isInput) { isInput = false; if (input && input.length>0) { arrayInputs.push(input); input = "" } } else if (isInput) { input += letter } } else { isInput = true } }) } return arrayInputs; }
Regex
function getInputs(string){ const regex = /%[^%]+%/g; console.log(String.prototype.match) const matches = string.match(regex); if(matches) return matches.map(match => match.slice(1, -1)); return []; }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
For
Regex
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
CP437 decode
CP437 decode 8000
CP437 decode 80000
String.indexOf vs RegExp.test (2)
Remove accents test
Comments
Confirm delete:
Do you really want to delete benchmark?