Skip to main content

ワークフロー文字列関数

Designer Cloud では、文字列関数はテキストデータに対して操作を実行します。文字列関数を使用してデータをクレンジングしたり、データを別の形式または大文字に変換したり、データに関するメトリックを計算したり、その他さまざまな操作を実行できます。文字列関数は、文字列データ型でのみ使用できます。

注記

Not all functions are supported between Standard mode and Cloud Native mode tools. For a list of supported functions, go to the respective Standard mode and Could Native mode function lists found on the Formula tool page.

Contains

Contains(String, Target, CaseInsensitive=1): 文字列内の特定の文字列を検索します。文字列 (String) にターゲット (Target) が含まれている場合は True、それ以外は False を返します。

Contains('123ABC', 'ABC') は、Trueを返します。

Contains('123ABC', 'abc') は、Trueを返します。

Contains('123ABC', 'abc', 0) は、Falseを返します。

CountWords

CountWords(string): 指定した文字列内の単語数を返します。単語はスペースで区切られた文字で定義されます。

CountWords("Basic Variables Households")3を返します。

CountWords("Basic Variables Age:Female (Pop)Age 1") は、5を返します。

DecomposeUnicodeForMatch

DecomposeUnicodeForMatch(String): Removes accents and expands compound characters while converting to a narrow string. All accents and other decorations are removed.

重要

This function is useful for matching only. It is not considered a normalized string.

The function is not designed for use with non-western character sets like Japanese. You should avoid using this function on strings that might contain wide characters and note that wide characters are converted to '?'.

Example

DecomposeUnicodeForMatch("Prénoms français")returns prenoms francais.

EndsWith

EndsWith(String, Target, CaseInsensitive=1): 文字列が特定の文字列で終わるどうかを確認します。文字列 (String) がターゲット (Target) で終わる場合は True、それ以外は False を返します。既定では大文字と小文字は区別されません。

EndsWith('123ABC', 'ABC')Trueを返します。

EndsWith('123ABC', 'abc')Trueを返します。

EndsWith('123ABC', 'abc', 0)Falseを返します。

FindNth

FindNth(Initial String, Target, Instance): Finds the instance (nth occurrence) of a target string in the initial string and returns the 0-indexed position of the instance. The function is case-sensitive and doesn’t accept negative parameters.

重要

In Cloud Native mode, Target and Instance must be static literal values.

Example

FindNth("Hello World","o",2)returns 7. The function finds the 2nd instance of "o" in the provided string and returns the 0-indexed position, which in this case is 7.

FindNth("Hello World","World",1)returns 6. The function finds the 1st instance of "World" in the provided string and returns the 0-indexed position of the first character, which in this case is 6.

FindNth("Hello World","o",1.8)returns 7. The function finds the 2nd instance (rounds 1.8 to the nearest integer) of "o" in the provided string and returns the 0-indexed position of the 2nd character, which in this case is 7.

FindNth("Hello World","world",1)returns -1. The function finds the 1st instance of "world" in the provided string and returns the 0-indexed position of the first character, which in this case is -1 (match not found due to case sensitivity).

FindNth("Hello World","l",0)returns -1. The function finds the 0th instance of "l" in the provided string and returns the 0-indexed position, which in this case is -1 (not found because the 0th position doesn't exist).

FindNth("Hello World","l",-1)returns -1. Negative parameters are not applicable, so the function returns -1 (not found).

FindNth("Hello World", Null(), 1)returns -1. Null and empty are not found.

FindNth(Hello world, "l", 1)returns an error. The function requires that the first 2 parameters are strings.

FindString

FindString 関数は大文字小文字を区別します。

FindString(String,Target): 文字列 (String) 内の特定の文字列 (Target) を検索し、文字列内での出現位置を返します。

文字列 (String) 内の ターゲット (Target) で最初に生成された 0 から始まるインデックスを返します。出現がない場合は -1 を返します。

FindString([Name], "John")文字列がJohnから始まる場合は 0 を返し、文字列がJohnから始まらない場合は -1 を返します。

IF (FINDSTRING([Name], "John") =0) THEN "John Smith" ELSE "Other" ENDIF は、文字列にJohnが含まれている場合は John Smith を返し、文字列にJohnが含まれていない場合は Other を返します。

GetLeft

GetLeft(String, Delimiter): Returns the left part of the provided (String) until the first instance of the specified 1 or more (Delimiter). In Cloud Native mode, Delimiter must be a static literal value.

注記

The Delimiter operator is case-sensitive. If you specify "a" as the delimiter, the function only uses "a" as the delimiter, not "A".

Example

GetLeft("Automated Analytics for All", " ") returns "Automated".

GetLeft("Enable fast, confident decisions across the enterprise.", ",") returns "Enable fast".

GetPart

GetPart(String, Delimiter, Index): Uses the specified 1 or more (Delimiters) to divide (String) into substrings, and returns the substring in the position that is specified in (Index). In Cloud Native mode, Delimiter must be a static literal value.

This function uses a 0-based index. For example, if Index is 2, the function returns the string from the position in index 2, which is the third substring.

注記

The Delimiter operator is case-sensitive. If you specify "a" as the delimiter, the function only uses "a" as the delimiter, not "A".

Example

GetPart("Automated Analytics for All", " ", 1) returns "Analytics".

GetPart("Automated Analytics for All", " ", 0) returns "Automated".

GetPart("Enable fast, confident decisions across the enterprise.", ", ", 5) returns "across". Note that this example uses 2 delimiters—a comma and a space. The function splits the string when it encounters either delimiter.

GetPart("January 1, 2023", " ", 2) returns "2023".

GetRight

GetRight(String, Delimiter): Returns the right part of the provided (String) after the first instance of the specified 1 or more (Delimiters). In Cloud Native mode, Delimiter must be a static literal value.

注記

The Delimiter operator is case-sensitive. If you specify "a" as the delimiter, the function only uses "a" as the delimiter, not "A".

Example

GetRight("Automated Analytics for All", " ")returns "Analytics for All".

GetRight("Enable fast, confident decisions across the enterprise.", ",") returns " confident decisions across the enterprise." (note the space beforeconfident in the return).

GetWord

GetWord(string, n): 文字列内の N 番目 (0 ベース) の単語を返します。単語はスペースで区切られた文字の集合として定義されます。0 ベースインデックスとは、最初の単語が 0 の位置 (0から始まる) にあるという意味です。

GetWord("Basic Variables Households", 0)"Basic"を返します。

GetWord("Basic Variables Households", 1)"Variables"を返します。

Left

Left(String, len): 文字列 (String) の最初の [len] 文字を返します。len が 0 より小さいか文字列の長さより大きい場合、指定した文字列は変更されずにそのまま返されます。

Left("92688", 3) は、926の値を返します。

Length

Length(String): 文字列 (String) の長さを返します。

Length("92688") は、5の値を返します。

LowerCase

LowerCase(String): 文字列を小文字に変換します。

LowerCase("M1P 1G6")"m1p 1g6"を返します。

MD5_ASCII

MD5_ASCII(String): Calculates the MD5 hash of the string. The string is expected to be only narrow characters. Wide characters are converted to '?' before computing the hash. Use for String types. You should avoid using this function on strings that might contain wide characters.

MD5_UNICODE

MD5_UNICODE(String): Calculates the MD5 hash of the string stored as UTF-16.

MD5_UTF8

MD5_UTF8(String): Calculates the MD5 hash of the string stored as UTF-8.

Example

Md5_Ascii("Lá"), stored as Latin1, it takes 2 bytes, 4C E1. The function computes the MD5 of the bytes, giving the result "0c0ee86cc87d87125ad8923562be952e".

Md5_Ascii("Lá ☢"), the ☢ character, being wide, is replaced with a '?', so it's as if you were computing Md5_Ascii("Lá?"). That is stored as Latin1 in 3 bytes, 4C E1 3F. The function computes the MD5 of the bytes, giving the result "a5a308ab19acf900efea8fc7b5b77b4d".

Md5_Unicode("Lá"), stored as UTF-16, it takes 4 bytes, 4C 00 E1 00. The function computes the MD5 of the bytes, giving the result "aa9969dfcca04249842cc457e5b3dd01".

Md5_Unicode("Lá ☢"), when stored as UTF-16 takes 8 bytes, 4C 00 E1 00 3C D8 C8 DF. The function computes the MD5 of the bytes, giving the result: "7c4762d93572dd02a8a405232e966b18".

Md5_Utf8("Lá"), stored as UTF-8, it takes 3 bytes, 4C C3 A1. The function computes the MD5 of the bytes, giving the result "68f00289dc3be140b1dfd4e031d733f1".

Md5_Utf8("Lá ☢"), when stored as UTF-8 takes 7 bytes, 4C C3 A1 F0 9F 8F 88. The function computes the MD5 of the bytes, giving the result "383fc0355db728a2078ce41a2ab6211b".

PadLeft

PadLeft(String, len, char): 文字列の左側を指定した文字で埋めて、指定した長さに揃えます。パディング文字(char)の長さが2文字以上の場合、最初の文字のみが使用されます。

PadLeft("M", 4, "x")"xxxM"を返します。

PadRight

PadRight(String, len, char): 文字列を指定した文字で、指定した長さまで右に埋め込みます。パディング文字(char)の長さが2文字以上の場合、最初の文字のみが使用されます。

PadRight("M", 4, "x")"Mxxx"を返します。

REGEX_CountMatches

REGEX_CountMatches(String,pattern,icase): Returns the count of matches within the string to the pattern.

icase is an optional parameter. When specified, the case must match. By default icase=1 (meaning ignore case). If set to 0, the case must match.

REGEX_Match

REGEX_Match(String,pattern,icase): 正規表現に一致する文字列を検索します。

文字列が最初の文字から最後までのパターンと一致するかどうかを示します。

  • 文字列の先頭から必ずしも始まらないものを探すには、パターンを '.*' で始めます。

  • 文字列の最後まで必ずしも行くとは限らないものを探すには、パターンを '.*' で終わらせます。

正規表現を正しく構築する方法の詳細な情報については、ブースト正規表現のPerl正規表現構文 ページを参照してください。

icase はオプションのパラメーターです。指定されると、大文字と小文字は一致する必要があります。既定で、icase=1 は大文字小文字の無視を意味します。0に設定すると、大文字と小文字が一致する必要があります。

REGEX_Match("123-45-6789", "\d{3}-\d{2}-\d{4}")-1 (True)を返します。

REGEX_Replace

REGEX_Replace(String, pattern, replace, icase): 正規表現検索パターンから得られた文字列を返し、文字列を置き換えます。

置換 (replace) のパラメーターは、以下に示すような指定された値、または「$1」などのマークされたグループのいずれかです。マークされたグループが二重引用符で囲まれていることを確認します。

icase はオプションのパラメーターです。指定されると、大文字と小文字は一致する必要があります。

  • 既定では icase=1 で、大文字小文字の無視を意味します。

  • 0に設定すると、大文字と小文字が一致する必要があります。

REGEX_Replace("Don't reveal your Social Security number, 123-45-6789","\d{3}-\d{2}-\d{4}", "CLASSIFIED") "あなたの社会保障番号、CLASSIFIEDを明らかにすることはありません"を返します。

REGEX_Replace("Change all domain names from alteryx@Alteryx.com","@.*\.", "@extendthereach.") ”alteryx@extendthereach.comからすべてのドメイン名を変更します”を返します。

REGEX_Replace("25 test","(\d+)\s.*","$1")は25を返します。

Replace

Replace(String, Target, Replacement): 文字列 (Target) の各出現箇所を文字列 (Replacement) で置き換えた後の文字列 (String) を返します。

Replace("Good judgment comes from experience", "experience", "awareness") は、「Good judgement comes from awareness」を返します。

ReplaceChar

ReplaceChar(String, y, z): 文字(y)を見つけるたびに文字(z)で置き換えた後の文字列(String)を返します。置換文字(z)が複数の文字を含む文字列である場合、最初の文字のみが使用されます。文字 (z) が空の場合、文字 (y) の任意の文字に一致する各文字 (String) は、削除されます。

ReplaceChar("abcdefb", "b", "_")"a_cdef_"を返します。

ReplaceChar("@a#b%c", "@,#,%", "_")"_a_b_c"を返します。

ReplaceFirst

ReplaceFirst(String, Target, Replacement): 最初に出現した文字列 (Target) を文字列 (Replacement) で置き換えた後の文字列 (String) を返します。

ReplaceFirst("abcdefb", "b", "_")"a_cdefb"を返します。

ReverseString

ReverseString(String): 文字列内のすべての文字の順番を反転します。

ReverseString("abcdefb") "bfedcba"を返します。

StartsWith

StartsWith(String, Target, CaseInsensitive=1): 文字列が特定の文字列で始まるかどうかを検索します。文字列 (String) が特定の文字列 (Target) で始まる場合は True、それ以外は False を返します。

StartsWith('ABC123', 'ABC')Trueを返します。

StartsWith('ABC123', 'abc')Trueを返します。

StartsWith('ABC123', 'abc', 0)Falseを返します。

STRCSPN

STRCSPN(String, y): Returns the length of the initial segment of the string (String) consisting of charactersnotin the string (y).

Example

STRCSPN("Bob's Amaco", "~!@#$%^&*'()")returns 3. This is a useful test to make sure there is no punctuation in the string.

StripQuotes

StripQuotes(String): 文字列の終わりから引用符またはアポストロフィーの一致したセットを削除します。

  • StripQuotes("Hello there") "Hello"を返します

  • StripQuotes("'Hello there,' she said.") "'Hello there,' she said"を返します。

  • StripQuotes('"Hello there," she said.') ""Hello there," she said"を返します。

STRSPN

STRSPN(String, y): Returns the length of the initial segment of the string (String) consisting of characters in the string (y).

Example

STRSPN("3034408896x105", "0123456789") returns 10. This is a useful test to make sure a string consists of a set of characters.

Substring

Substring(String, start, length): (Start) で始まり、(length) で終了する部分文字列を返します (指定されている場合)。

Substring("949-222-4356", 4, 8) は、「222-4356」を返します。

Substring("949-222-4356", 4, 6) は、「222-43」を返します。

Substring("949-222-4356", 4) は、「222-4356」を返します。

TitleCase

TitleCase(String): 文字列をタイトルケースに変換します。

TitleCase("john smith")"John Smith"を返します。

Trim

Trim(String, y): 文字列 (y) 内の文字を文字列 (String) の終わりから削除します。yはオプションで、既定では空白類をトリミングします。TRIM 関数の例では、指定された文字がトリミングされることに注意してください。文字の順序は関係ありません。

Trim("!see instructions!!!", "!") は、「see instructions」を返します。

Trim(" Test123 ") は、「Test123」を返します。

TrimLeft

TrimLeft(String, y): 文字列 (y) の文字を文字列 (String) の先頭から削除します。yはオプションで、既定では空白類をトリミングします。

TrimLeft("** special invitation ", " *") "special invitation "を返します。

TrimRight

TrimRight(String, y): 文字列 (y) の文字を文字列 (String) の末尾から削除します。yはオプションで、既定では空白類をトリミングします。

TrimRight("John Smith ")"John Smith"を返します。

TrimRight("John Smith**","*")"John Smith"を返します。

トリミングする文字の文字列を渡す場合、TRIM 関数は文字の順序を考慮しません。文字列を "list" として扱うため、リスト内のすべての文字がトリミングされます。文字列を置換する場合は、式で Replace 関数または REGEX 関数を使用します。

Uppercase

Uppercase(String): 文字列を大文字に変換します。

Uppercase("John Smith") は、「JOHN SMITH」を返します。

UuidCreate

UuidCreate(): Creates a unique identifier.

Example

UuidCreate()returns a unique value such as ba131836-1ba3-4d42-8f7e-b81a99c2e838.