TEXTBEFORE

TEXTBEFORE 函數會傳回一個字串值,字串值是由顯示在原始字串值中指定子字串之前的所有字元所組成。

TEXTBEFORE(來源字串, 搜尋字串, 次數)

來源字串: 任何數值

搜尋字串: 要搜尋的字串值。

次數: 可留空的值,用於表示要符合搜尋字串來源字串中的出現次數(1 代表第一次符合,2 代表第二次符合,⋯,-1 代表最後一次符合,-2 代表倒數第二次符合,⋯)。若省略,則會設為 1。

附註

  • 依照預設,若搜尋字串來源字串中出現多次,TEXTBEFORE 會傳回截至(且不包括)第一次出現的文字。

  • 若在來源字串中沒有找到搜尋字串,或是無法找到指定的出現次數,則會傳回錯誤。

  • 搜尋字串中允許 REGEX 進行更複雜的搜尋。

  • 依照預設,搜尋不區分大小寫。若要在搜尋時考量大小寫,請使用 REGEX 函數進行搜尋字串

範例

=TEXTBEFORE("Marina Cavanna", " ") 會傳回「Marina」。

=TEXTBEFORE("If you want to return the text before the second to, in case there are multiple to occurrences.", "to", 2) 會傳回「If you want to return the text before the second」。

=TEXTBEFORE("All the text before the very last occurrence of the word the", "the", -1) 會傳回「All the text before the very last occurrence of the word」。

=TEXTBEFORE("Get all the text before an email like marina@example.com", REGEX("([A-Z0-9a-z._%+-]+)@([A-Za-z0-9.-]+\.[A-Za-z]{2,4})")) 會傳回「Get all the text before an email like」。

=TEXTBEFORE("All the text before the table of contents"," ",3) 會傳回「All the text」。

Morty Proxy This is a proxified and sanitized view of the page, visit original site.
有幫助?
字元限制: 250
最大字元限制為 250。
感謝您的寶貴意見。
Morty Proxy This is a proxified and sanitized view of the page, visit original site.