我使用regexp_extract()
从字符串中提取子字符串。
一种子字符串类似于:Abc-Def-ghi
我使用regexp_extract(s, '^[a-zA-Z0-9]{1,}\-[a-zA-Z0-9]{1,}\-[a-zA-Z0-9]{1,}')
)来获取它。
其他类型的子字符串如下所示:wp.Abc-Def-ghi
如何使用一个regexp_extract()
来获取这两种类型的字符串?
答案 0 :(得分:3)
regexp_extract(s, '^([a-zA-Z0-9]{2}\.)?(a-zA-Z0-9]{3}-?){3}')