Reputation: 99
I have sentence field in my table which is similar to this
id text
100 the quick %brown fox %jumped over the %lazy dog
101 how are %you? Nice to %meet you
I want to extract only the words that have the % appended to them so my output would be
%brown
%jumped
%lazy
%you
%meet
So I tried using the regexp_split_to_array but failed miserably. My table is in Postgres.
Upvotes: 0
Views: 69
Reputation: 51416
what exactly did not work for you with regexp? eg:
t=# select regexp_matches('the quick %brown fox %jumped over the %lazy dog','%[a-z]{1,}','g');
regexp_matches
----------------
{%brown}
{%jumped}
{%lazy}
(3 rows)
Upvotes: 1