If the regular expression of go is slow, there was an article on the Internet, so did you want to make it similar? Which is faster, string or regexp? (I didn't compare it with the code I told you because it was just similar.)
go regular-expression
The string
is probably faster.
The simple replacement process is The original text of Kafka's "transformation" is about 50 times faster
The reason why I said probably at the beginning is that the strings
package and regexp
package have about 3D features.
The former provides simple string manipulation, such as the Index function and Replace functions.
The latter offers a regular expression called "slow".
Therefore, if you use the former, you have to reinvent the functions necessary for regular expressions.
Self-made regular expression functions can be early or late depending on the producer's skill.
In extreme cases, if you implement regular expressions in exactly the same algorithm as regexp, the speed would be "slow."
Then, when asked if the regexp
package is a useless regular expression, that's not the case.
It uses an algorithm called Thompson NFA
that is different from regular expression packages such as Perl and Python, which is disadvantageous when the number of characters is small, but prevents exponential slowness.
The article has a distinctive graph of the former O(2^n) order and the latter O(n^2) order, which is an interesting.
Another caveat is that the regular expression is extremely slow to uncompiled, so it is important to use the regexp
package in an appropriate implementation rather than simply making it a villain.
Reference: How to deal with regexp
915 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
618 Uncaught (inpromise) Error on Electron: An object could not be cloned
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
611 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.