Regexp Find Digit between two hyphens

I have a str that looks like this:
str = '7-6-1'
and I would like to return 6.
I was able to return 7 using ^[^-]*[^ -] but can't seem to find the expression to return the second item.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 23 de Oct. de 2019

0 votos

(?<=-)\d(?=-)
Is one of the ways.
(?-)\d(?-)
might work

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Centro de ayuda y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by