如何根據A列中的部分字符串將公式寫入填充列B?例如:
A欄有
夏威夷大學
夏威夷社區學院
B列目前是空白的,它是新的。 我想根據A列的數據填充它。
例如...
如果行A中有一個帶有“大學”的字符串,那麼我希望B行說“大學”
如果行A中有一個包含“社區”的字符串,那麼我希望行B打印“社區”
我希望大學或社區的每個實例都能實現這一點。
Re:如何根據A列中的部分字符串將公式寫入填充B列?它的工作非常感謝!
Re:如何根據A列中的部分字符串將公式寫入填充B列?我相信這個公式是一個更簡單的版本 @uday_guntupalli 建議
If(Contains( UpperCase( :Column A, "UNIVERSITY" ), "University",
Contains( UpperCase( :Column A, "COMMUNITY" ), "Community"
);Re:如何根據A列中的部分字符串將公式寫入填充B列? @caspears ,
我提供的腳本有多個部分。
第1部分:
創建一個包含示例數據的新表以進行演示
第2部分:
您尋求的實際公式
在您的情況下,您基本上只需要公式中的部分
dt = New Table(); // Create a new table - you dont need this
dt << New Column("Col1",Character,Continuous,<< Set Values({"University of Toronoto","Community College of Tempe","Temple University","Arizona University","Community College of Wisconsin"})); // Create a column with sample data for demo - you dont need this
DesList = {"University","university","Community","Community"}; // you actually dont need this
dt << New Column("Check",Character,Continuous,Formula(If(!IsMissing(Regex(Char(:Col1),".*[uU]niversity*")),
"University";
,
If(!IsMissing(Regex(Char(:Col1),".*[cC]ommunity*")),
"Community";
)
)
)
); // In this part of the script all you need is the part under "Formula" 這是你需要的部分。 你不能使用:Col1。它需要由您正在執行搜索的列替換
)If(!IsMissing(Regex(Char(:Col1),".*[uU]niversity*")),
"University";
,
If(!IsMissing(Regex(Char(:Col1),".*[cC]ommunity*")),
"Community"<BR /> )<BR />
Re:如何根據A列中的部分字符串將公式寫入填充B列?你好:
它什麼都沒做:

Re:如何根據A列中的部分字符串將公式寫入填充B列? @caspears ,
您可以使用Contains()或Regex()來執行此操作。我將提供一個Regex()的例子
dt = New Table();
dt << New Column("Col1",Character,Continuous,<< Set Values({"University of Toronoto","Community College of Tempe","Temple University","Arizona University","Community College of Wisconsin"}));
DesList = {"University","university","Community","Community"};
dt << New Column("Check",Character,Continuous,Formula(If(!IsMissing(Regex(Char(:Col1),".*[uU]niversity*")),
"University";
,
If(!IsMissing(Regex(Char(:Col1),".*[cC]ommunity*")),
"Community";
)
)
)
);
有關“正則表達式”的更多解釋 - 請看這裡 - https://community.jmp.com/t5/Discussions/Regex-help/mp/48759#M27716
或者關注Craige Hales博客( https://community.jmp.com/t5/Uncharted/Regex/ba-p/21008/jump-to/first-unread-message )