翻譯頁面
本頁面由英文在 AI 協助下翻譯而成。若兩者有出入,請以英文版本為準。
REGEXP_REPLACE
將相符的子字串取代為取代字串。
另請參閱:
[SELECT] [ 正規表示式參考 ]
語法
SELECT REGEXP_REPLACE(source, pattern, replacement) FROM <multipartIdentifier>;
引數
source
字串常值或字串資料行,其中符合正規表示式 pattern 的部分會取代為 replacement。
pattern
要搜尋的正規表示式模式。
replacement
取代字串。
取代字串中支援對擷取群組
\1到\9的反向參考。
傳回值
傳回字串。
範例
取代資料行中的正規表示式模式
- StackQL
- 結果
select name,
regexp_replace(json_extract(properties, '$.timeCreated'), 'T.*', '') as date_created
from azure.compute.virtual_machines
WHERE subscription_id = '273769f6-545f-45b2-8ab8-2f14ec5768dc';
|------|--------------|
| name | date_created |
|------|--------------|
| vm0 | 2022-09-14 |
|------|--------------|
| vm1 | 2022-09-14 |
|------|--------------|
| vm2 | 2022-09-14 |
|------|--------------|
如需詳細資訊,請參閱 https://github.com/nalgeon/sqlean/blob/main/docs/re.md。