Regex Postgresql中的Posix正则表达式是否要从引用的文本中提取?
我试图从PostgreSQL中的列值中提取一些字符串 因此,基本上,我在表中的列中有文本,看起来像:Regex Postgresql中的Posix正则表达式是否要从引用的文本中提取?,regex,postgresql,posix,Regex,Postgresql,Posix,我试图从PostgreSQL中的列值中提取一些字符串 因此,基本上,我在表中的列中有文本,看起来像: blah blah blah.... <something="AValueIWant">....dfdf.gd d.fg d.fd... <something="AnotherValueIWant">. select regexp_matches(body, <some kind of pattern that doesn't work>, 'g') fro
blah blah blah.... <something="AValueIWant">....dfdf.gd d.fg d.fd... <something="AnotherValueIWant">.
select regexp_matches(body, <some kind of pattern that doesn't work>, 'g') from tablebody
让我们将列称为“body”,将表称为“tablebody”
到目前为止,我有一些类似于:
blah blah blah.... <something="AValueIWant">....dfdf.gd d.fg d.fd... <something="AnotherValueIWant">.
select regexp_matches(body, <some kind of pattern that doesn't work>, 'g') from tablebody
选择regexp\u匹配项(正文,您可以尝试以下操作:
<something="([^"]+)">
或者…你有主意了
select a[1]
from (
select regexp_matches(body, '="(.+?)"', 'g') a
from tablebody
) s
但我宁愿使用专门的HTML解析器,除非这是一项非常快速且繁琐的工作。是否“something”键总是相同的?
select a[1]
from (
select regexp_matches(body, '="(.+?)"', 'g') a
from tablebody
) s