Returning the same token twice in regex expression

13 ビュー (過去 30 日間)
Armando
Armando 2016 年 11 月 4 日
コメント済み: Armando 2016 年 11 月 4 日
By parsing the string 'avcadebc', how can I get regexp to return two instances of 'bc' knowing that 'a' occurs twice?
This is what I've attempted, but this is only returns a single 'bc':
'(?:a.*)(bc)'
The code I'm using-
a = 'avcadebc';
b = regexp(a, '(?:a.*)(bc)', 'tokens');
Thanks.
  4 件のコメント
Nick Counts
Nick Counts 2016 年 11 月 4 日
Armando, it is not clear to us what rule you are trying to create.
Is this the rule you are after?
IF a string contains both 'a' AND 'bc'
THEN return 'bc' for each instance of 'a'
?
Armando
Armando 2016 年 11 月 4 日
Sorry about the confusion. You have it correct.

サインインしてコメントする。

回答 (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