例如,TableA:
ID1 ID2
123 abc
123 def
123 ghi
123 jkl
123 mno
456 abc
456 jkl
Run Code Online (Sandbox Code Playgroud)
我想对123进行字符串搜索并返回所有相应的值.
pp = Cases[#, x_List /;
MemberQ[x, y_String /;
StringMatchQ[y, ToString@p, IgnoreCase -> True]], {1}] &@TableA
{f4@"ID2", f4@pp[[2]]}
Run Code Online (Sandbox Code Playgroud)
上面,p是输入,或123.这只返回ID2的一个值.如何获取ID2的所有值?
table = {{ID1, SQLDateTime[{1978, 1, 10, 0, 0, 0.`}]},
{ID2, SQLDateTime[{1999, 1, 10, 0, 0, 0.`}]},
{ID3, SQLDateTime[{2010, 9, 10, 0, 0, 0.`}]},
{ID4, SQLDateTime[{2011, 1, 10, 0, 0, 0.`}]}}
Run Code Online (Sandbox Code Playgroud)
我想返回tableSQLDateTime在去年(DatePlus[{-1, "Year"}])内的所有情况.如何指定搜索这些案例?
因为我正在使用一个非常复杂的表,在变量位置有令人讨厌的重复值,所以我想在特定的行和列之间进行字符串搜索.
例如:
table={{"header1", "header2", "header3",
"header4"}, {"falsepositive", "falsepositive", "name1",
"falsepositive"}, {"falsepositive", "falsepositive", "name2",
"falsepositive"}, {"falsepositive", "falsepositive",
"falsepositive", "falsepositive"}}
%//TableForm=
header1 header1 header1 header1
falsepositive falsepositive name1 falsepositive
falsepositive falsepositive name2 falsepositive
falsepositive falsepositive falsepositive falsepositive
Run Code Online (Sandbox Code Playgroud)
我如何查找字符串,例如,在第三列,第一行到第二行?
我想用来Which根据字符串在表中的位置来分配值.
例如,
Which[string matched in location one, value, matched in location two, value2]
Run Code Online (Sandbox Code Playgroud)