【发布时间】:2020-09-30 03:49:11
【问题描述】:
如何在字符串中找到某些字符的位置。这是我的尝试:
Example = "Hello, this is Tom. I wonder, should I go run?";
SearchedCharacters = {'.','!',',','?'};
%Plan one
Locations = strfind(Example, SearchedCharacters);
%Plan two
Locations = cellfun(@(s)find(~cellfun('isempty',strfind(C,s))),SearchedCharacters,'uni',0);
我的两个计划都出错了。
最后。有了字符串中字符的位置,我想确定字符串中倒数第二个感兴趣的字符。在这种情况下,它将是“,”(就在“wonder”一词之后),位置 = 29。
我们将不胜感激。 谢谢。
【问题讨论】:
标签: string matlab find location