TextBetween - 指令碼與圖表函數
TextBetween() 會傳回輸入字串中在指定為分隔符號之字元之間出現的文字。
語法:
TextBetween(text,
delimiter1, delimiter2[, n])
傳回的資料類型: 字串
引數:
text
|
原始字串。 |
delimiter1
|
指定要在 text 中搜尋的第一個分隔字元 (或字串)。 |
delimiter2
|
指定要在 text 中搜尋的第二個分隔字元 (或字串)。 |
n
|
定義要在其中進行搜尋的分隔符號配對。例如,值 2 傳回 delimiter1 第二次出現與 delimiter2 第二次出現之間的字元。 |
TextBetween('<abc>', '<', '>') | Returns 'abc' |
TextBetween('<abc><de>', '<', '>',2) | Returns 'de' |
TextBetween('abc', '<', '>') TextBetween('<a<b', '<', '>') | Both examples return NULL. If any of the delimiter is not found in the string, NULL is returned. |
TextBetween('<>', '<', '>') | Returns a zero-length string. |
TextBetween('<abc>', '<', '>', 2) | Returns NULL, as n is greater than the number of occurrences of the delimiters. |
Load *, textbetween(Text,'<','>') as TextBetween, textbetween(Text,'<','>',2) as SecondTextBetween; Load * inline [ Text <abc><de> <def><ghi><jkl> ];
Result
Text | TextBetween | SecondTextBetween |
---|
<abc><de> | abc | de |
<def><ghi><jkl> | def | ghi |