Google+ Followers

vrijdag 31 januari 2014

Why I like PostgreSQL more than MySQL: Substring() can use regular expressions

The SUBSTRING() function accepts regular expressions and can return a matching block:

SUBSTRING('<a href="">The Dolmen</a>' , 'href=\"([^\"]+)\"')

 The Dolmen
(1 row)

Notice that the expression includes elements that are not returned in the result.
And be aware that there can be only one block in the regular expression, SUBSTRING() can after all only return one value.