Using or with strfind
7 次查看(过去 30 天)
显示 更早的评论
Hello,
I have two patterns p1 (or) p2, to be found within a single string, str. The objective is to get the position if either of those two patterns is found. But the following doesn't seem to work:
position=strfind(str,p1 || p2)
How to modify this statement to get the result?
Thanks.
0 个评论
回答(1 个)
KSSV
2021-2-12
position1 = strfind(str,p1) ;
position2 = strfind(str,p2) ;
OR
position = strfind(str,[p1, p2]) ;
3 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!