Hello,
Please help me find the last instance of a string within a string.
For Example, I want to find ABC in this string.
123ABC456ABC789ABC
It should return 16, because it's the last instance of ABC.
Thank you.
Solved! Go to Solution.
In case anyone wants the expression only...
LENGTH([Field1]) - (FINDSTRING(REVERSESTRING([Field1]), REVERSESTRING("ABC")) + 2)
Referenced solution courtesy of @MarqueeCrew : https://community.alteryx.com/t5/Alteryx-Designer-Desktop-Discussions/Last-instance-of-a-character/t...
Hi, @RonGatmaitan
1- If your "ABC" is manual input, then use the formula:
Length(REGEX_Replace([Txt], '^(.*?)ABC[^A-Z]*?$', '$1')) + 1
2- If input from filed, then
Length(REGEX_Replace([Txt], '^(.*?)' + [FindStr] + '[^A-Z]*?$', '$1')) + 1
You can use ReverseString function of Formula tool. Please find the attached workflow.
*Alteryx normally counts string position from 0 index basis, but it seems you start count from 1, my WF is made so.
@RonGatmaitan as you can see, many ways to do it. Excellent solutions by @flying008 and @gawa !
Thanks for the replies, @caltang, @gawa and @flying008! Will try these out!
If it helps, you can mark @gawa @flying008 and my solution as accepted solutions to close the thread! Thanks @RonGatmaitan !
Done, @caltang! Thanks to all 3 of you!