[英]Excel formula to find two words after the prefix
我正在將 Jira 問題導出到 Excel 以從描述中提取數據。
格式示例如下:“作者:Bob Bryant 這是一個測試 JIRA”
這樣整個字符串在 Excel 中占據一個單元格
我需要做一個=IF(ISNUMBER(SEARCH("*Author*",Description)),"Author:","")
但我需要它代替“作者:”之后的 2 個詞(用戶全名),在這種情況下,我需要它來代替“鮑勃·布萊恩特”
不幸的是,Excel 不能使用正則表達式(這會容易得多)。 您可以使用SUBSTITUTE
function 通過臨時文本替換來解決它。
和:
Prefix
- 帶有前綴的單元格,例如“作者:”Description
- 帶有原始/源文本的單元格這是您需要的公式是:
=IF(ISERR(SEARCH(Prefix;Description));"(no "&Prefix&" found)";IFERROR(TRIM(MID(Description;LEN(Prefix)+1;SEARCH("$$$";SUBSTITUTE(Description&" ";" ";"$$$";3))-LEN(Prefix)));"(too short)"))
讓我們更深入地解釋一下:
=IF(
ISERR(SEARCH(Prefix;Description)); -- consider only cells with the right prefix (Author:)
"(no "&Prefix&" found)"; -- Prefix not found: return message
IFERROR( -- Prefix found: proceed
TRIM( -- remove any leading/trailing spaces
MID( -- return the text between prefix and 3rd space
Description;
LEN(Prefix)+1; -- start after the prefix
SEARCH( -- end before the substituted text ($$$)
"$$$";
SUBSTITUTE( -- substitute 3rd space (most important!)
Description&" "; -- add extra space (in case there's no other text after the name)
" ";
"$$$";
3))-LEN(Prefix)));"(too short)"))
請注意,您可能需要更換;
在您的公式中使用,
(取決於您的系統區域設置/區域設置)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.