Revision 14271
Added by Aaron Marcuse-Kubitza over 10 years ago
trunk/schemas/util.sql | ||
---|---|---|
2752 | 2752 |
CREATE FUNCTION extract_by_regexp(pattern text, str text, group_ integer DEFAULT 1) RETURNS text |
2753 | 2753 |
LANGUAGE sql IMMUTABLE |
2754 | 2754 |
AS $$ |
2755 |
SELECT (regexp_matches(str, pattern))[group_]
|
|
2755 |
SELECT COALESCE((SELECT regexp_matches(str, pattern))[group_], str)
|
|
2756 | 2756 |
$$; |
2757 | 2757 |
|
2758 | 2758 |
|
Also available in: Unified diff
bugfix: schemas/util.sql: extract_by_regexp(): needs surrounding COALESCE in case no match