Revision 14225
Added by Aaron Marcuse-Kubitza over 10 years ago
trunk/schemas/util.sql | ||
---|---|---|
5462 | 5462 |
|
5463 | 5463 |
|
5464 | 5464 |
-- |
5465 |
-- Name: trim_parens(text); Type: FUNCTION; Schema: util; Owner: - |
|
5466 |
-- |
|
5467 |
|
|
5468 |
CREATE FUNCTION trim_parens(str text) RETURNS text |
|
5469 |
LANGUAGE sql IMMUTABLE |
|
5470 |
AS $_$ |
|
5471 |
SELECT CASE WHEN /*base case*/inner_str IS NULL THEN str |
|
5472 |
ELSE util.trim_parens(inner_str) END |
|
5473 |
FROM (SELECT (SELECT regexp_matches(str, '^\((.*)\)$'))[1] AS inner_str) s |
|
5474 |
$_$; |
|
5475 |
|
|
5476 |
|
|
5477 |
-- |
|
5465 | 5478 |
-- Name: truncate(regclass); Type: FUNCTION; Schema: util; Owner: - |
5466 | 5479 |
-- |
5467 | 5480 |
|
Also available in: Unified diff
schemas/util.sql: added trim_parens()