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

SPSS keyboard combination alters encoding -

Socket.connect doesn't throw exception in Android -

iphone - How do I keep MDScrollView from truncating my row headers and making my cells look bad? -