Hi, can someone help me with a function? I have a ...
# general
l
Hi, can someone help me with a function? I have a string from which I need to remove the ID and the values in the square brackets as in below.: Value: 1897 [WWEU-EC] CPW Group USA -> Result CPW Group USA 357 [WWEU-EC] Wärte Corporation -> Wärte Corporation 692 [WWEU-EC] Kustan -> Kustan I tried using REGEXP_SUBSTR but I'm getting stuck
e
Use INSTR to get the position of the closing bracket -> ] and then SUBSTR to use the position from the INSTR call to get the remaining string after the ]
s
This works, just replace the hardcoded string with your field id
REGEXP_REPLACE(REGEXP_SUBSTR('1897 [WWEU-EC] CPW Group USA','] [^:]+*$'),']','')
🎉 1
🙏 1
e
SUBSTR('Your [Bracketed] String', INSTR('Your [Bracketed] String', ']') + 1, LENGTH('Your [Bracketed] String')
l
Thanks Sandii! This works very well!
s
It basically says remove everything before the last bracket and replace with empty string, similar to what Eric B says to do
l
nice! Thanks all for helping!