跳至主要內容
翻譯頁面

本頁面由英文在 AI 協助下翻譯而成。若兩者有出入,請以英文版本為準。

REGEXP_SUBSTR

從輸入字串傳回符合指定模式的子字串。

另請參閱:
[SELECT] [ 正規表示式參考 ]


語法​

SELECT REGEXP_SUBSTR(source, pattern) FROM <multipartIdentifier>;

引數​

source
字串常值或字串資料行,您要依據由正規表示式(pattern)定義的模式從中擷取子字串。

pattern
要搜尋的正規表示式模式。

傳回值​

傳回字串。


範例​

依據正規表示式擷取子字串​

select name,
json_extract(properties, '$.storageProfile.imageReference.offer') as os,
regexp_substr(
json_extract(properties, '$.storageProfile.imageReference.exactVersion'),
'[0-9][0-9]\.[0-9][0-9]') as os_version
from azure.compute.virtual_machines
WHERE subscription_id = '273769f6-545f-45b2-8ab8-2f14ec5768dc';

如需詳細資訊,請參閱 https://github.com/nalgeon/sqlean/blob/main/docs/re.md。