필터 지우기
필터 지우기

How to use contains method to find indices for only certain strings. For example, I have RA-IS1 and RA-IS1-CRT, but I only want to find RA-IS1 indices.

조회 수: 3 (최근 30일)
Hi! I have two excel sheets, and I am trying to find the indices where a certain string from one sheet is contained on the other sheet using the contains method. Some of the strings contain parts of other strings, but also more characters. For example, I have strings RA-IS1 and RA-IS1-CRT. Currently, if I look for the indices where RA-IS1 is contained it will also give me the indices where RA-IS1-CRT is contained. How do I get the contains indices for only the smaller string?
  댓글 수: 1
John D'Errico
John D'Errico 2020년 10월 9일
편집: John D'Errico 2020년 10월 9일
Since contains gives you either case, then even though you want to use contains, you cannot do so.
"If your only tool is a hammer, then every problem looks like a nail."
The implication being, you need to learn how to use other tools. Perhaps you are looking to test for exact equality. You may wish to consider other tools, perhaps regexp. Or perhaps you need to test the strings you do find using contains to see if more is present in the string.

댓글을 달려면 로그인하십시오.

답변 (1개)

Sudhakar Shinde
Sudhakar Shinde 2020년 10월 9일
Instead of contains you can try:
  1. regexp
  2. strcmp
strcmp - could be your interest.

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by