Patterns / Regular Expressions in string.gsub

Hey Facepunch,
I need a little help with using Patterns. For example purposes lets say I’m trying to make a ban time script:

[lua]local steamid = “STEAM:0:1:23456789”
local name = “Bastinka”
local str = string.Implode(";",{steamid,name,250})
local pattern = “[%d]+”
local replacement = “10”

print(string.gsub( str, pattern, replacement ))[/lua]

Instead of replacing every number, how could I make the pattern only replace the number after the second ; in the string?

This way I can have the string I want printed to me.


Oh wow, although I read the wiki entry on patterns, does $ just get the first occurrence from the end of the string to the start?


Pretty much. It ‘anchors’ the the pattern to the end of the string.