简体   繁体   中英

How do I locate last occurrence of a substring in a RapidMiner CE calculation?

I am trying to locate the last occurrence of a character or substring in a string (first occurrence from the end) in RapidMiner calculation field. I can use index() function to locate first occurrence. rindex() function is designed to find last occurrence, but it seems that RM community edition does not support it. Can someone suggest any other alternatives?

For example:

String = "This is first and this is second and this is last"
index(String, "is") results in 6. (First "is" located at the 6th character)

I am interested in the location of last "is" which should be 43.

Thank you.

(?:.*?(\bis\b))*

Try this.Grab the capture.The last group is the one you want.Or else you can also replace,find the location of first non space character left and subtract -2 to get your result.

See demo.

http://regex101.com/r/aX5eP7/1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM