How could I select all n-grams, ie. substrings of length n from a string using SQL? For example, the 3-grams of string example are exa, xam, amp, mpl, ple.
I'm using PostgreSQL to be more precise.
postgresql
How could I select all n-grams, ie. substrings of length n from a string using SQL? For example, the 3-grams of string example are exa, xam, amp, mpl, ple.
I'm using PostgreSQL to be more precise.
Best Answer
This does the trick:
Here it is in a function:
Use it like: