I guess, nothing is wrong, I was just thinking of a way for isolating a variable name from the rest of the regex, i.e. variable name is not terminated.
Is this possible?: [[:$ipv4:]] or I should do (?:$ipv4)?
Comment on Re^2: Defining your own regex character class