Using or with strfind
조회 수: 5 (최근 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!