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
Post a Comment