I need help with extracting value after last underscore from below string example.
Example string is AB_1234567_awesome-weather_think_so_whatever_9876543
Expected Solution is 9876543
Appreciate your time & help.
Solved! Go to Solution.
You want to set the Regex tool to parse and use the pattern,
.*_(\d+)
Hope this helps,
Philip
If it's not digits at the end then you can just use,
.*_(.*)
Or if it is definitely just digits, you could also use,
(\d+)$
This works! thank you so much Philip.
Some non-regex methods for you,
If you're feeling brave,
reversestring(getword(replace(ReverseString([Field1]), '_', ' '), 0))
If you're feeling clever,
FileGetFileName(replace([Field1], '_', '/'))
As "solved" by @PhilipMannering you are using a regular expression (a hammer) where a string function is called for.
Right([Example String],Findstring(ReverseString([Example String]),"_"))
The RegEx is roughly 2x as expensive as this combination of string functions is. The reverse string function combined with the find string function determines the LENGTH required of the right function.
Both solutions work.
Cheers,
Mark
I'm glad to see that you posted an alternative to the RegEx expression. I'm happier to see a different string function than the one that I posted. For bonus happiness, I'm glad to see that my expression is still the fastest.
I think that getword() is an expensive function.
Cheers,
Mark
Good to know! Can you attach your (or a) workflow for comparing the speed of each method? I'd quite like to know how I can assess which methods are the best quickest.
P
I'm not in front of my computer now but.....
text input - generate rows (1,000,000)
cache the generate rows
connect this to a formula tool and place that tool into container 1.
repeat for formula/ container 2.
turn on workflow configuration runtime option for performance monitoring.
for each formula (other container disabled) run 3 times.
take the middle timings from the results messages.
Example:
1000 ms vs 2000 ms
1.9 seconds vs 2.9 seconds
I'll create a YouTube video tomorrow morning.
P.S. I've created a new post documenting the performance profiling technique that I used.
MarqueeCReW-Quick-Lesson-Performance-Profiling
Cheers,
Mark
User | Count |
---|---|
18 | |
14 | |
13 | |
9 | |
8 |