我想选择前3个特殊字符的案例。
例如前三个字符包含356 | else build_aux (DistMap.find x map)::acc source (DistMap.find x map)
^^^^^^^^^^^^^^^^^^^^
Error: This expression has type 'a but an expression was expected of type
'a list
The type variable 'a occurs inside 'a list
的情况。
整个值的长度可以变化。例如"I22"
或"I228"
,但它们具有共同的前三个字符"I2279"
我通常使用"I22"
但这很乏味,因为我必须输入compute variable_name= "I228".
的所有变体,例如"I22"
,"I228"
等。
如果我可以仅基于相同的前三个字符来选择案例,那就容易得多了
答案 0 :(得分:1)
您可以使用char.cubstr
函数来查找字符串变量中的前三个字符。例如:
if char.substr(variable_name,1,3)="I22" keep_this=1.
或:
select cases if char.substr(variable_name,1,3)="I22".