I want to update all matched url's in db.table.column. I want to add a param in the end of the url and leave everything else as it was before.
I have tried this:
UPDATE table SET column = regexp_replace(column, 'url_matcher', (substring(column, 'url_matcher') || 'end_param');
UPDATE
"db"."emailTemplate"
set
"bodyText" = regexp_replace(
"bodyText",
'({{(@root\.)?app\.url}})[a-zA-Z0-9@:%._\+~#\-&={}\/?]{2,255}',
(substring("bodyText" from '({{(@root\.)?app\.url}})[a-zA-Z0-9@:%._\+~#\-&={}\/?]{2,255}') || '¶m={{param}}')
),
"bodyHtml" = regexp_replace(
"bodyHtml",
'({{(@root\.)?app\.url}})[a-zA-Z0-9@:%._\+~#\-&={}\/?]{2,255}',
(substring("bodyHtml" from '({{(@root\.)?app\.url}})[a-zA-Z0-9@:%._\+~#\-&={}\/?]{2,255}') || '¶m={{param}}')
);
but the substring does not match the whole url it only matches {{app.url}} or {{@root.app.url}} everything else of the url is not matched.
When I alone run regexp_replace("bodyHtml", [same pattern], 'replace_thing') it matches the whole url and replaces that with "replace_thing". So in one case the regex pattern works, and in the other it doesn't. All fields that didn't match a url is not updated, but when using the substring function also, as in my example. all fields that didn't match a url is updated with null.
Can I not use nested functions like this? if not - how can I achieve what I want otherwise?
Does other regex pattern rules apply to substring function than regexp_replace?
emaxple of column value: Hello user, click here {{app.url}}/home:search=true&item=33 to visit your page
regexp_replace will match: {{app.url}}/home:search=true&item=33, substring will only match {{app.url}}
after update the column value should look like this:
Hello user, click here {{app.url}}/home:search=true&item=33¶m={{param}} to visit your page
but it ends up looking like this:
Hello user, click here {{app.url}}¶m={{param}} to visit your page
a field like this: Hello you have been registered! will look like this: null but should be untouched.

'({{(@root\.)?app\.url}}[a-zA-Z0-9@:%._+~#&={}/?-]{2,255})'regex and'\1¶m={{param}}'replacement. See rextester.com/MHVIX41178.