matches
설명
예제
텍스트 일치
string형 배열을 만듭니다.
str = ["Mercury","Venus","Earth","Mars"]
str = 1x4 string
"Mercury" "Venus" "Earth" "Mars"
"Earth"
와 일치하는 문자열을 구합니다. 값이 1
인 요소의 위치가 str
에서 일치하는 문자열의 위치에 대응하는 논리형 배열을 반환합니다.
TF = matches(str,"Earth")
TF = 1x4 logical array
0 0 1 0
TF
를 사용하여 str
의 요소를 다시 참조하는 방식으로 일치 부분을 표시합니다.
str(TF)
ans = "Earth"
패턴을 사용한 16진수 일치
R2020b 이상
숫자를 나타내는 string형 배열을 만듭니다. 일부 숫자는 접두사 0x
를 사용하는 16진수입니다.
str = ["137","0xA7B","0x1248","72","0xG7"]
str = 1x5 string
"137" "0xA7B" "0x1248" "72" "0xG7"
16진수 숫자와 일치하는 패턴을 만듭니다. 단일 16진수 숫자와 일치하도록 하려면 숫자 하나, A
에서 F
(대문자) 또는 a
에서 f
(소문자) 사이에 있는 문자 하나와 일치하는 패턴을 지정하십시오. 그런 다음 0x
로 시작하고 그 뒤에 16진수 숫자 중 하나가 나오는 패턴을 지정합니다.
pat = digitsPattern(1) | characterListPattern("A","F") | characterListPattern("a","f"); pat = "0x" + asManyOfPattern(pat)
pat = pattern
Matching:
"0x" + asManyOfPattern(digitsPattern(1) | characterListPattern("A","F") | characterListPattern("a","f"))
일치하는 str
요소를 찾습니다. (마지막 요소는 오류가 있으므로 일치하지 않습니다. G
는 16진수 숫자가 아닙니다.)
TF = matches(str,pat)
TF = 1x5 logical array
0 1 1 0 0
일치 부분을 표시하려면 TF
를 사용하여 str
의 요소를 참조하십시오.
str(TF)
ans = 1x2 string
"0xA7B" "0x1248"
pattern 객체를 만드는 함수 목록은 pattern
항목을 참조하십시오.
16진수 숫자에 대한 자세한 내용은 16진수 값과 2진수 값 항목을 참조하십시오.
여러 개의 문자열 일치
string형 배열을 만듭니다.
str = ["Mercury","Venus","Earth","Mars"]
str = 1x4 string
"Mercury" "Venus" "Earth" "Mars"
"Venus"
또는 "Earth"
와 일치하는 str
의 요소를 찾습니다.
TF = matches(str,["Venus","Earth"])
TF = 1x4 logical array
0 1 1 0
TF
를 사용하여 str
의 요소를 참조하는 방식으로 일치 부분을 표시합니다.
str(TF)
ans = 1x2 string
"Venus" "Earth"
대/소문자 무시하기
string형 배열을 만듭니다.
str = ["Mercury","Venus","Earth","Mars"]
str = 1x4 string
"Mercury" "Venus" "Earth" "Mars"
"earth"
와 일치하는 str
의 요소를 찾습니다. 이때 대/소문자는 무시됩니다.
TF = matches(str,"earth",IgnoreCase=true)
TF = 1x4 logical array
0 0 1 0
일치하는 string형을 표시합니다.
str(TF)
ans = "Earth"
입력 인수
확장 기능
tall형 배열
메모리에 담을 수 없을 정도로 많은 행을 가진 배열을 계산할 수 있습니다.
C/C++ 코드 생성
MATLAB® Coder™를 사용하여 C 코드나 C++ 코드를 생성할 수 있습니다.
스레드 기반 환경
MATLAB®의 backgroundPool
을 사용해 백그라운드에서 코드를 실행하거나 Parallel Computing Toolbox™의 ThreadPool
을 사용해 코드 실행 속도를 높일 수 있습니다.
이 함수는 스레드 기반 환경을 완전히 지원합니다. 자세한 내용은 스레드 기반 환경에서 MATLAB 함수 실행하기 항목을 참조하십시오.
분산 배열
Parallel Computing Toolbox™를 사용하여 대규모 배열을 클러스터의 결합된 메모리에 걸쳐 분할할 수 있습니다.
사용법 관련 참고 및 제한 사항:
pat
는 string형 배열, 문자형 벡터 또는 문자형 벡터로 구성된 셀형 배열이어야 합니다.
자세한 내용은 분산 배열을 사용하여 MATLAB 함수 실행 (Parallel Computing Toolbox) 항목을 참조하십시오.
버전 내역
R2019b에 개발됨
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)