Returning the same token twice in regex expression

13 visualizaciones (últimos 30 días)
Armando
Armando el 4 de Nov. de 2016
Comentada: Armando el 4 de Nov. de 2016
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 comentarios
Nick Counts
Nick Counts el 4 de Nov. de 2016
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 el 4 de Nov. de 2016
Sorry about the confusion. You have it correct.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by