function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
asadimasadim 

FIND alternative: search from right to left (similar to INSTRREV)

Anybody knows if there's a way to tell a WF field update formula to look for a string from the end? Something like INSTRREV in Access.

 

Thanks!

Pradeep_NavatarPradeep_Navatar

You can use  RIGHT(text, num_chars) . It returns the specified number of characters from the end of a text string. Hope this helps.

asadimasadim

RIGHT does a different thing than what I want. I want to get the index of a character/string from the end. I'm looking for something like FIND but searching from right to left (FIND searches from left to right). Basically I'm looking for the equivalent of INSTRREV in Access.

hmayeshmayes

Were you able to find a solution to this? I'm looking to find the last space in a string, which seems very simple but I'm finding it impossible because I don't know how many spaces are in the the string, and as you noted find only works from left to right.

Starz26Starz26

hmayes wrote:

Were you able to find a solution to this? I'm looking to find the last space in a string, which seems very simple but I'm finding it impossible because I don't know how many spaces are in the the string, and as you noted find only works from left to right.


For this use: lastIndexOf



Starz26Starz26

asadim wrote:

RIGHT does a different thing than what I want. I want to get the index of a character/string from the end. I'm looking for something like FIND but searching from right to left (FIND searches from left to right). Basically I'm looking for the equivalent of INSTRREV in Access.


Are you looking to do a search like:

 

Phrase: 'This World' Search for: row (Found Right to Left at r in Wor)

 

Or

 

Phrase: 'This World' Search for: Wor (Found Right to Left at W in Wor)

 

And are you trying to search across object using SOSL or just searching a string from a specific field (trigger, apex, etc)

hmayeshmayes

Starz26 wrote:

hmayes wrote:

Were you able to find a solution to this? I'm looking to find the last space in a string, which seems very simple but I'm finding it impossible because I don't know how many spaces are in the the string, and as you noted find only works from left to right.


For this use: lastIndexOf




That sounds exactly like what I'm looking for. However when I try to use that function (in a workflow field update) I get the error "Error: Unknown function lastIndexOf. Check spelling." I also don't see it as an available function in the formula editor. What am I missing? Thanks.

 

Hal