tag-regex

Benchmark created by Zane Wolfgang Pickett on


Test runner

Ready to run.

Testing in
TestOps/sec
Regex
"http://www.google.com?key=http://sadad".replace(/^((http)?(s)?(:)?(\/\/)?)/, 'https://');

"https://www.google.com".replace(/^((http)?(s)?(:)?(\/\/)?)/, 'https://');

"//www.google.com".replace(/^((http)?(s)?(:)?(\/\/)?)/, 'https://');
ready
IndexOf + String Cat
url = "http://www.google.com?key=http://sadad"
if (url.indexOf('//') === 0) {
  url = 'https:' + url
} else if (url.indexOf('http:') !== 0 && url.indexOf('https:') !== 0) {
  url = 'https://' + url
}

url = "https://www.google.com"
if (url.indexOf('//') === 0) {
  url = 'https:' + url
} else if (url.indexOf('http:') !== 0 && url.indexOf('https:') !== 0) {
  url = 'https://' + url
}

url = "//www.google.com"
if (url.indexOf('//') === 0) {
  url = 'https:' + url
} else if (url.indexOf('http:') !== 0 && url.indexOf('https:') !== 0) {
  url = 'https://' + url
}
ready
Regex Direct Port
"https://"+"http://www.google.com?key=http://sadad".replace(/(^\/\/)|(^http:\/\/)|(^https:\/\/)/, '');

"https://"+"https://www.google.com".replace(/(^\/\/)|(^http:\/\/)|(^https:\/\/)/, '');

"https://"+"//www.google.com".replace(/(^\/\/)|(^http:\/\/)|(^https:\/\/)/, '');
ready
Regex Compact
"https://"+"http://www.google.com?key=http://sadad".replace(/^(\w{4,5}\:)?(\/\/)/, '');

"https://"+"https://www.google.com".replace(/^(\w{4,5}\:)?(\/\/)/, '');

"https://"+"//www.google.com".replace(/^(\w{4,5}\:)?(\/\/)/, '');
ready

Revisions

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

  • Revision 1: published by Zane Wolfgang Pickett on