如何在Redshift中从字符串中解析主机? [英] How to parse host out of a string in Redshift?

查看:69
本文介绍了如何在Redshift中从字符串中解析主机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找与蜂巢的parse_url(...,'HOST').

Postgres文档说它包含URL解析器其全文搜索.该博客文章具有正则表达式,它可能是防弹的,也可能不是.最好是什么?

Postgres docs say it has a URL parser as part of its full text search. This blog post has a regex which may or may not be bulletproof. What is best?

推荐答案

如果您不使用Redshift,我会说使用PL/Perlu,PL/Python或其他一种过程语言来获取常规URL解析器".由于您使用的是Pg 8.1的专有分支,因此我不得不怀疑自己会遇到hacky regexp.

If you weren't using Redshift, I'd say "use PL/Perlu, PL/Python, or one of the other procedural languages to get a regular URL parser". Since you're on a proprietary fork of Pg 8.1 you're going to have to settle for a hacky regexp I suspect.

无法从SQL级别访问全文搜索URL解析器.您可以编写一个C扩展名以很轻松地向SQL公开该函数,但是您当然不能在Redshift中安装该扩展名,因此它对您没有任何好处.

There is no way to access the full-text search URL parser from the SQL level. You could write a C extension to expose the function to SQL quite easily, but of course you can't install the extension in Redshift, so again it won't do you any good.

是时候滥用正则表达式了.

Time to abuse regular expressions.

(顺便说一句,感谢您实际上说您正在进行redshift;太多的人说"PostgreSQL"是指基于PostgreSQL的ParAccel托管版本")

(BTW, thanks for actually saying you're on redshift; too many people say "PostgreSQL" when they mean "a vaguely PostgreSQL based hosted version of ParAccel")

这篇关于如何在Redshift中从字符串中解析主机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆