Back to top
  Back to overview

Parse functions

These functions can be used when parsing email addresses and URL web addresses.

Function Description
parse::email::domain() Parses and returns an email domain from an email address
parse::email::user() Parses and returns an email username from an email address
parse::url::domain() Parses and returns the domain from a URL
parse::url::fragment() Parses and returns the fragment from a URL
parse::url::host() Parses and returns the hostname from a URL
parse::url::path() Parses and returns the path from a URL
parse::url::port() Parses and returns the port number from a URL
parse::url::query() Parses and returns the query string from a URL

parse::email::domain

The parse::email::domain function parses and returns and email domain from a valid email address.

parse::email::domain(string) -> value

The following example shows this function, and its output, when used in a select statement:

SELECT * FROM parse::email::domain("info@surrealdb.com");
"surrealdb.com"

If the argument is not a string, then the value will be cast to a string before the function is run:

SELECT * FROM parse::email::domain(12345);
null

parse::email::user

The parse::email::user function parses and returns and email username from a valid email address.

parse::email::user(string) -> value

The following example shows this function, and its output, when used in a select statement:

SELECT * FROM parse::email::user("info@surrealdb.com");
"info"

If the argument is not a string, then the value will be cast to a string before the function is run:

SELECT * FROM parse::email::user(12345);
null

parse::url::domain

The parse::url::domain function parses and returns the domain from a valid URL.

parse::url::domain(string) -> value

The following example shows this function, and its output, when used in a select statement:

SELECT * FROM parse::url::domain("https://surrealdb.com:80/features?some=option#fragment");
"surrealdb.com"

If the argument is not a string, then the value will be cast to a string before the function is run:

SELECT * FROM parse::url::domain(12345);
null

parse::url::fragment

The parse::url::fragment function parses and returns the fragment from a valid URL.

parse::url::fragment(string) -> value

The following example shows this function, and its output, when used in a select statement:

SELECT * FROM parse::url::fragment("https://surrealdb.com:80/features?some=option#fragment");
"fragment"

If the argument is not a string, then the value will be cast to a string before the function is run:

SELECT * FROM parse::url::fragment(12345);
null

parse::url::host

The parse::url::host function parses and returns the hostname from a valid URL.

parse::url::host(string) -> value

The following example shows this function, and its output, when used in a select statement:

SELECT * FROM parse::url::host("https://surrealdb.com:80/features?some=option#fragment");
"surrealdb.com"

If the argument is not a string, then the value will be cast to a string before the function is run:

SELECT * FROM parse::url::host(12345);
null

parse::url::path

The parse::url::path function parses and returns the path from a valid URL.

parse::url::path(string) -> value

The following example shows this function, and its output, when used in a select statement:

SELECT * FROM parse::url::path("https://surrealdb.com:80/features?some=option#fragment");
"/features"

If the argument is not a string, then the value will be cast to a string before the function is run:

SELECT * FROM parse::url::path(12345);
null

parse::url::port

The parse::url::port function parses and returns the port from a valid URL.

parse::url::port(string) -> value

The following example shows this function, and its output, when used in a select statement:

SELECT * FROM parse::url::port("https://surrealdb.com:80/features?some=option#fragment");
80

If the argument is not a string, then the value will be cast to a string before the function is run:

SELECT * FROM parse::url::port(12345);
null

parse::url::query

The parse::url::query function parses and returns the query from a valid URL.

parse::url::query(string) -> value

The following example shows this function, and its output, when used in a select statement:

SELECT * FROM parse::url::query("https://surrealdb.com:80/features?some=option#fragment");
"some=option"

If the argument is not a string, then the value will be cast to a string before the function is run:

SELECT * FROM parse::url::query(12345);
null