LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  strfind from right

    Employee
    Posted 11-16-2015 07:48

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: svimes

    Can one do a string find from the right rather than the left eg to get the last "a" in the string rather than the first.

    I know I could do a progressive find then right but that will mean lots of IF statements / iterations if there are a lot of "a"s in the string.


  • 2.  RE: strfind from right

    Employee
    Posted 12-18-2015 08:00

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: mgajdosik

    You can reverse the string using the following syntax and then use strFind on it... this is simple solution that will work for you assuming you have small amount of data...

    reversed = ""
    i = FIELD.len()
    while (i>-1) {
    reversed = reversed + ( FIELD.substr(i,1))
    i = i-1
    }

    there is also a python way, which is way nice, but you would have to use python node for that... in python you have rfind function... to reverse string in python you can do
    'STRING'[::-1] which will result in 'GNIRTS'