Reputation: 2150
I'm trying to build a regex match with variables as part of the matched string:
var_a := 'somestring'
var_b := 'someotherstring'
IF EXISTS (SELECT 1 FROM some_table WHERE some_field ~* 'var_a.+?(?=\-)\-var_b)')
How do I insert the variables into the string? Like in js you can simply do:
`${var_a} restofstring`
Upvotes: 0
Views: 231
Reputation:
You could use the format()
function:
WHERE some_field ~* format('%s.+?(?=\-)\-%s)', var_a, var_b)
Upvotes: 1