Another regexp parsing question

2 views (last 30 days)
Duke
Duke on 15 Mar 2014
Answered: per isakson on 15 Mar 2014
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!

Accepted Answer

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

More Answers (0)

Categories

Find more on Characters and Strings in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!