Ruby get last * in a string -


i have string different data , stars well. how can index of last *? example

hello * there * * 

now how can index of 3rd *?

use string.rindex:

returns index of last occurrence of given substring or pattern (regexp) in str. returns nil if not found.

x = 'hello * there * *' puts x.rindex('*') # 16 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Socket.connect doesn't throw exception in Android -

SPSS keyboard combination alters encoding -