Regexp Find Digit between two hyphens

3 次查看(过去 30 天)
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.

采纳的回答

Walter Roberson
Walter Roberson 2019-10-23
(?<=-)\d(?=-)
Is one of the ways.
(?-)\d(?-)
might work

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