Another regexp parsing question

1 次查看(过去 30 天)
I have a string with 2 hex values like:
'.text 0x54a65b23 0x45 (hello)'
I want to pull the full hex numbers out of this string. Like my last question I just can't get it right. I can get the '0x' part of each number but I can't get the full string. I tried a lot of different varitions of this '0x[1234567890abcdef]'. I've tried doing '+' and '*' after each character but it refuses to get the numbers after the 0x. Thanks!

采纳的回答

per isakson
per isakson 2014-3-15
The "+" should be after "]"
str = '.text 0x54a65b23 0x45 (hello)';
cac = regexp( str, '0x[0-9a-fA-F]+', 'match' )
returns
cac =
'0x54a65b23' '0x45'

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 String Parsing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by