I have the following code snippet in SQL to select the next piece of text after ABC DEF that's of variable length:
SELECT trim('ABC DEF ' FROM regexp_substr(my_field, 'ABC DEF ([^ ]+)')) FROM my_table
Sample Data:
'{random text here} ABC DEF {my_variable_length_keyword} {random text here}'
Expected Output:
{my_variable_length_keyword}
While this works, it only accounts for cases where there is one space after ABC DEF. How would I deal with cases where there are tabs, new lines, or multiple spaces before the next word?
I've tried:
SELECT trim('ABC DEF ' FROM regexp_substr(my_field, 'ABC DEF\s+([^ ]+)')) FROM my_table
But this doesn't yield any result.
Can someone please help me out with this? Thank you!