parse_url
Returns the specified part of a given URL. Valid values for partToExtract are HOST, PATH, QUERY, REF, PROTOCOL, AUTHORITY, FILE, and USERINFO. When the second parameter is QUERY, the third parameter can be used to extract the value of a specific parameter.
Syntax
parse_url(string <urlString>, string <partToExtract [, string <keyToExtract>])
Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| urlString | Yes | STRING | URL. |
| partToExtract | Yes | STRING | Valid values are HOST, PATH, QUERY, REF, PROTOCOL, AUTHORITY, FILE, and USERINFO. Case-insensitive. |
| keyToExtract | No | STRING | When partToExtract is QUERY, extracts the corresponding value based on the key. |
Return Values
Returns a value of type STRING.
- If urlString, partToExtract, or keyToExtract is NULL, NULL is returned.
- If partToExtract is not a valid value, NULL is returned.
Example Code
Returns example.com.
select parse_url('file://username@example.com:666/over/there/index.dtb?type=animal&name=narwhal#nose', 'HOST'); Returns /over/there/index.dtb.
select parse_url('file://username@example.com:666/over/there/index.dtb?type=animal&name=narwhal#nose', 'PATH'); Returns animal.
select parse_url('file://username@example.com:666/over/there/index.dtb?type=animal&name=narwhal#nose', 'QUERY', 'type'); Returns nose.
select parse_url('file://username@example.com:666/over/there/index.dtb?type=animal&name=narwhal#nose', 'REF'); Returns file.
select parse_url('file://username@example.com:666/over/there/index.dtb?type=animal&name=narwhal#nose', 'PROTOCOL'); Returns username@example.com:666.
select parse_url('file://username@example.com:666/over/there/index.dtb?type=animal&name=narwhal#nose', 'AUTHORITY'); Returns username.
select parse_url('file://username@example.com:666/over/there/index.dtb?type=animal&name=narwhal#nose', 'USERINFO'); What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot