02-26-2016 10:52 AM
gregoryj wrote:Edit1: Kudos to James!
Edit2: Wait a second, he said from a string to a string.
Thanks for the kudos anyways
@Gregory wrote:
@James.M wrote:I ran a benchmark on the multiple solutions in this thread and there is a very clear winner. Replacing a subset of 8 zeroes wins by a mile:
And I learned you can run a For Loop "1M" times instead of "1000000", awesome!
Just change the display format to SI Notation!
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
02-26-2016 11:54 AM
02-26-2016 12:01 PM
Oh, good point and it looks like it had an affect. The concatenate solution slows down a bit, the Search/Replace speeds up, and the Replace Subset solution speeds up a bit but is already so fast its hard to tell by how much.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
02-26-2016 12:24 PM
Sam_Sharp's idea is not that bad if we replace the for loop with initialize array.
02-26-2016 12:54 PM
@1abvi3w wrote:Sam_Sharp's idea is not that bad if we replace the for loop with initialize array
Yes! That was what I was looking for! I knew there had to be a way to avoid the for loop (I was hoping for something like 'repeat string' - but initialise array with a concatenate strings works too!).
02-26-2016 01:11 PM
Here's one more option that I think is slightly cleaner and simpler, and should be fast too. Use the version on the left if all inputs strings are no longer than 8 characters, otherwise use the version on the right:
02-26-2016 05:47 PM - edited 02-26-2016 05:58 PM
Sometimes it is easier to operate on byte arrays (The 48 is decimal U8):
(Still needs some exception handing if the string input can be longer than the total intended length)
02-29-2016 04:08 AM
Hi,
Many many thanks to you! I worte this question on Friday by hoping that on weekend it can be answered and on Monday I can look for a solution. But what I see here is awesome 🙂 there is solution even with benchmark! I want to accept all of this as solution but it is not possible to accept all of them 🙂
Thanks again.
02-29-2016 10:10 AM - edited 02-29-2016 10:10 AM
@kahlenberg wrote:I want to accept all of this as solution but it is not possible to accept all of them 🙂
In fact, you can select multiple replies As Solution.
There's a strange phenomenon on this board. Every time a string-related question is asked, there are always many different solutions and different answers given. I think the developers here love a good string parsing challenge!
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
02-29-2016 10:26 AM
@James.M wrote:
I think the developers here love a good string parsing challenge!
I hate them, because invariably there will be some indecipherable regex solution requiring three paragraphs of explanations.
That's why my solution is basically all blue. I don't like strings. reminds me too much of text based code.... 😄
(Just kidding...or am I?)