翻訳ページ
このページは AI の支援を受けて英語から翻訳されています。内容が異なる場合は英語版が正となります。
REGEXP_SUBSTR
入力文字列から、指定したパターンに一致する部分文字列を返します。
関連項目:
[SELECT] [ 正規表現リファレンス ]
構文
SELECT REGEXP_SUBSTR(source, pattern) FROM <multipartIdentifier>;
引数
source
正規表現(pattern)で定義したパターンに基づいて部分文字列を抽出する、文字列リテラルまたは文字列型の列です。
pattern
検索する正規表現パターンです。
戻り値
文字列を返します。
例
正規表現に基づいて部分文字列を抽出する
- StackQL
- 結果
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';
|------|---------------|------------|
| name | os | os_version |
|------|---------------|------------|
| vm0 | UbuntuServer | 16.04 |
|------|---------------|------------|
| vm1 | UbuntuServer | 16.04 |
|------|---------------|------------|
| vm2 | UbuntuServer | 20.04 |
|------|---------------|------------|
詳細については、https://github.com/nalgeon/sqlean/blob/main/docs/re.md を参照してください。