Get the Position of the Last Instance of a String Within a String
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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...
Alteryx ACE
https://www.linkedin.com/in/calvintangkw/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@RonGatmaitan as you can see, many ways to do it. Excellent solutions by @flying008 and @gawa !
Alteryx ACE
https://www.linkedin.com/in/calvintangkw/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thanks for the replies, @caltang, @gawa and @flying008! Will try these out!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
If it helps, you can mark @gawa @flying008 and my solution as accepted solutions to close the thread! Thanks @RonGatmaitan !
Alteryx ACE
https://www.linkedin.com/in/calvintangkw/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Done, @caltang! Thanks to all 3 of you!
