how to use regexp for negative and positive integers?
    13 次查看(过去 30 天)
  
       显示 更早的评论
    
hello,
I have a trouble using regexp. I read a sensor value that can contain negative or positive integers and I need both. but until now I only get one of it(only positive integers o negative integers). here is my code that only reads positive integers:
FSR1 = regexp(FSR1,'\d+(\.)?(\d+)?','match');
and these are some types of integers that I`m reading:
 '204'
    '203'
    '191'
    '133'
    '63'
    '-28'
    '-109'
    '-145'
    '-196'
    '-134'
can someone help me, please?
采纳的回答
  Andrei Bobrov
      
      
 2016-6-3
        
      编辑:Andrei Bobrov
      
      
 2016-6-3
  
         a = {'204'
      '203'
      '191'
      '133'
      '63'
      '-28'
      '-109'
      '-145'
      '-196'
      '-134'}
FSR1 = str2double(regexp(a,'[-]?\d+(\.)?(\d+)?','match','once'))
0 个评论
另请参阅
类别
				在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


