假设我有一个字符串变量" Fruit"
.
通常,我使用strtrim()
删除前导空格。因此," Fruit"
变为"Fruit"
。
但是,如果前导空格是不间断的,即char(160)
,则 strtrim 以及它的表亲 -deblank
并且strtok
- 不能删除这个前导空格。
我也尝试使用 for 循环替换" Fruit"
,"Fruit"
但 for 循环似乎无法识别" Fruit"
,这表明我识别错误。
这是我的 for 循环
for i=1:height(T)
if T.Foods(i) == " Fruit"
T.Foods(i) = "Fruit"
end
end
有什么方法可以删除这个前导的、不间断的空格,或者至少用没有空格的变量替换它?