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 -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -