Parsing everything between quotation using regular expression

8 ビュー (過去 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 Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by