how to replace string on the last ???

string = '12-34-56-78'

string.gsub(((string.reverse.match /(.*?)-.*/)[1].reverse), 'love')

Warning: unnecessarily complicated maybe, but works. :slight_smile:

Later,
Vish

mmm Looks like my post was lost to the ether

β€˜12-34-56-78’[-2,2] = β€œ91”

HTH
Daniel

Sorry I misunderstood.

β€œ123-456-856”.sub( /\d+$/, β€œ999” )
β€œ123-456-999”

/\d+$/ Matches the last numeric digits in the string, since it’s anchored to the end of the string, and replaces them with the second argument.

HTH
Daniel

Daniel: that's cool, didn't think of that :slight_smile:

Vish