ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Do like @pan64 posted. Larry himself does not recommend regex. But the other point of this is to go with the simplest approach. Regex is great and perl really cemented into the minds of many but it's not often simple.
May be there was, only the OP knows certainly. But maybe someone posts a benchmark to show the results for a million goes of each.
"A million goes of" anything at all is basically going to be an exercise in brutalizing the memory-manager.
String manipulation, no matter how you do it, can be very brutal because it "fills the air with sawdust and wood chips." I once worked with a high-performance section of an application which purposely used C(!) to do certain string operations ... in fixed arrays. It accepted dynamic-string inputs, dutifully tested them for excessive length, then performed a variety of operations in the "old school" way, purposely avoiding the dynamic allocation of memory. The working-set size (amount of VM typically allocated to and needed by the process) was dramatically reduced, and performance enhanced on the machine as a whole ... which ran multiple copies of this system at the same time.
"A million goes of" anything at all is basically going to be an exercise in brutalizing the memory-manager.
String manipulation, no matter how you do it, can be very brutal because it "fills the air with sawdust and wood chips." I once worked with a high-performance section of an application which purposely used C(!) to do certain string operations ... in fixed arrays. It accepted dynamic-string inputs, dutifully tested them for excessive length, then performed a variety of operations in the "old school" way, purposely avoiding the dynamic allocation of memory. The working-set size (amount of VM typically allocated to and needed by the process) was dramatically reduced, and performance enhanced on the machine as a whole ... which ran multiple copies of this system at the same time.
:-)
That is the usual solution to C++ problems as well... as well as any language using dynamic strings.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.