필터 지우기
필터 지우기

Parsing everything between quotation using regular expression

조회 수: 15 (최근 30일)
KnowledgeSeeker
KnowledgeSeeker 2014년 2월 7일
댓글: Walter Roberson 2019년 3월 21일
I m working on a code that parse whatever occur between the quations as shown in my example below
raw="square format" tag_id=
I want parse only between the quotations (highlighted in bold) "whateverhere even space or dots" parse me
your help is highly appreciated
  댓글 수: 2
per isakson
per isakson 2014년 2월 7일
  • What has tag_id= to do with the question?
  • raw="square format" tag_id= is that a sample string of text, out of which you want to extract square format?
Walter Roberson
Walter Roberson 2014년 2월 7일
You say "whateverhere even spaces or dots". Does that include the possibility of double-quotes ?

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

채택된 답변

Ken Atwell
Ken Atwell 2014년 2월 7일
I think you want:
raw='"square format" tag_id='
regexp(raw, '"(.*?)"', 'tokens')
That gives you a cell array of all text found within double quotes, and nothing else. KEN
  댓글 수: 5
Guillaume
Guillaume 2019년 3월 21일
sst, please start a fresh question rather than commenting on a 5 year old answer.
Walter Roberson
Walter Roberson 2019년 3월 21일
regexp(raw, '"(.*?)(?<!\\)"', 'tokens')
You might want to add the 'once' option if you only expect one occurance.

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

추가 답변 (0개)

카테고리

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