Saltar para o conteúdo principal

Text.Combine

Concatenates a list of text values into one text value.

Syntax

Text.Combine(
texts as list,
optional separator as text
) as text

Remarks

Returns the result of combining the list of text values, texts, into a single text value. Any null values present in texts are ignored. An optional separator used in the final combined text can be specified.

Examples

Example #1

Combine text values "Seattle" and "WA".

Text.Combine({"Seattle", "WA"})

Result:

"SeattleWA"

Example #2

Combine text values "Seattle" and "WA", separated by a comma and a space.

Text.Combine({"Seattle", "WA"}, ", ")

Result:

"Seattle, WA"

Example #3

Combine the values "Seattle", <code>null</code>, and "WA", separated by a comma and a space. (Note that the <code>null</code> is ignored.)

Text.Combine({"Seattle", null, "WA"}, ", ")

Result:

"Seattle, WA"

Category

Text.Transformations

More examples

Reverse Uri.Parts

This function constructs a full URL based on individual fields in the record.

Uri.FromParts = (parts) =>
let
port = if (parts[Scheme] = "https" and parts[Port] = 443) or (parts[Scheme] = "http" and parts[Port] = 80) then "" else ":" & Text.From(parts[Port]),
div1 = if Record.FieldCount(parts[Query]) > 0 then "?" else "",
div2 = if Text.Length(parts[Fragment]) > 0 then "#" else "",
uri = Text.Combine({parts[Scheme], "://", parts[Host], port, parts[Path], div1, Uri.BuildQueryString(parts[Query]), div2, parts[Fragment]})
in
uri;

Web.Curl

Get a curl command string for a given url and options (as used in Web.Contents()) for debugging purposes.

(url as text, optional options as record) as text =>
let
query = options[Query],
headers = options[Headers],
qList = List.Transform(Record.FieldNames(query), each _ & "=" & Record.Field(query, _)),
hList = List.Transform(Record.FieldNames(headers), each " -H """ & _ & ": " & Record.Field(headers, _) & """"),
qJoined = try "?" & Text.Combine(qList, "&") otherwise "",
hJoined = try Text.Combine(hList, "") otherwise "",
Return = "curl """ & url & qJoined & """" & hJoined & " -v"
in
Return