StringReplace (Command)
StrReplace (Function)
RegExReplace (Function)
Which one is faster? StringReplace? Any script available out there for testing purpose only?
StringReplace vs StrReplace vs RegExReplace
Re: StringReplace vs StrReplace vs RegExReplace
Check the forum for "benchmark", and this: https://autohotkey.com/boards/viewtopic.php?t=6413 OR that ...
https://autohotkey.com/board/topic/9186 ... code-runs/
https://autohotkey.com/board/topic/9186 ... code-runs/
Re: StringReplace vs StrReplace vs RegExReplace
It will depend on what you are doing of course, but in most cases, if you can do it with strReplace (or StringReplace), it will be fastest, especially if you can use StringCaseSens, On. The difference between strReplace and stringReplace is probably very small.
Cheers.
Cheers.
- Delta Pythagorean
- Posts: 627
- Joined: 13 Feb 2017, 13:44
- Location: Somewhere in the US
- Contact:
Re: StringReplace vs StrReplace vs RegExReplace
I prefer to use RegExReplace because I'm used it it, but I do think it needs a bit of a fix up.
[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat
Re: StringReplace vs StrReplace vs RegExReplace
Is StrReplace function based on StringReplace command or based on RegExReplace function?
If it's based on StringReplace command, so it means that StringReplace command is automatically faster?
If it's based on StringReplace command, so it means that StringReplace command is automatically faster?
Re: StringReplace vs StrReplace vs RegExReplace
To answer your two questions:
- StrReplace aims to replace StringReplace and to be a function version of it, but is modelled to resemble RegExReplace. In terms of version number, StrReplace is relatively new (1.1.21.00 - March 28, 2015).
- To find out which of two commands/functions/approaches is faster, try benchmark tests, i.e. repeat the same procedure say ~100000 times, and compare speeds to be sure. E.g.
[Speedtest] Bitwise Hacks - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=37217
StrReplace v. StringReplace:
- StrReplace and StringReplace should be roughly the same speed-wise.
- StringReplace will be removed in AHK v2.
- StringReplace had various disadvantages:
- it has replace once as default (StrReplace has replace all)
- the awkward UseErrorLevel approach to count replacements (StrReplace uses an output variable)
- it's a command not a function, so you can't do direct output (unlike InStr/StrReplace/RegExReplace), before StrReplace was available people were using RegExReplace to achieve this
StrReplace v. RegExReplace:
- StrReplace has the advantage over RegExReplace, that it's faster and you don't have to escape special characters
- RegExReplace has the advantage over StrReplace, of all the special RegEx replacement options
- RegExReplace is generally slower than StrReplace. Even using StrReplace 26/52 times, can be faster than one-liners like: RegExReplace(vText, "[A-Za-z]")
- StrReplace aims to replace StringReplace and to be a function version of it, but is modelled to resemble RegExReplace. In terms of version number, StrReplace is relatively new (1.1.21.00 - March 28, 2015).
- To find out which of two commands/functions/approaches is faster, try benchmark tests, i.e. repeat the same procedure say ~100000 times, and compare speeds to be sure. E.g.
[Speedtest] Bitwise Hacks - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=37217
StrReplace v. StringReplace:
- StrReplace and StringReplace should be roughly the same speed-wise.
- StringReplace will be removed in AHK v2.
- StringReplace had various disadvantages:
- it has replace once as default (StrReplace has replace all)
- the awkward UseErrorLevel approach to count replacements (StrReplace uses an output variable)
- it's a command not a function, so you can't do direct output (unlike InStr/StrReplace/RegExReplace), before StrReplace was available people were using RegExReplace to achieve this
StrReplace v. RegExReplace:
- StrReplace has the advantage over RegExReplace, that it's faster and you don't have to escape special characters
- RegExReplace has the advantage over StrReplace, of all the special RegEx replacement options
- RegExReplace is generally slower than StrReplace. Even using StrReplace 26/52 times, can be faster than one-liners like: RegExReplace(vText, "[A-Za-z]")
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA