I want to find all string inside of [ ], for example, I expect to get three results '1ac', 'd2' and 'k3' for following string
'[1ac][d2][k3]'
However, when I use
regexp('[1ac][d2][k3]','(?<=\[).+(?=\])','match')
I will get '1ac][d2][k3'.
How can I get three results '1ac', 'd2' and 'k3' instead?

 채택된 답변

Cris LaPierre
Cris LaPierre 2021년 2월 4일

0 개 추천

Use extractBetween instead.
str = '[1ac][d2][k3]'
str = '[1ac][d2][k3]'
newStr = extractBetween(str,"[","]")
newStr = 3x1 cell array
{'1ac'} {'d2' } {'k3' }

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

제품

질문:

2021년 2월 4일

댓글:

2021년 2월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by