I have this following string:
message_id = "7bb19406-f97a-47b3-b42c-40868d2cef5b-1661496224@example.com"
I would like to extract the last part between - .* @
which is 1661496224
With forward and backward lookup, it starts from first matches of -
but I want to match from last match of -
:
#!/bin/ruby
message_id = "7bb19406-f97a-47b3-b42c-40868d2cef5b-1661496224@example.com"
message_id.match(/(?<=\-).*(?=\@)
output:
#<MatchData "f97a-47b3-b42c-40868d2cef5b-1661496224">
How to capture the least match (1661496224
) between two characters?