how to use regexp for negative and positive integers?
    13 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    dafniz91
 am 3 Jun. 2016
  
    
    
    
    
    Kommentiert: dafniz91
 am 3 Jun. 2016
            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?
Akzeptierte Antwort
  Andrei Bobrov
      
      
 am 3 Jun. 2016
        
      Bearbeitet: Andrei Bobrov
      
      
 am 3 Jun. 2016
  
         a = {'204'
      '203'
      '191'
      '133'
      '63'
      '-28'
      '-109'
      '-145'
      '-196'
      '-134'}
FSR1 = str2double(regexp(a,'[-]?\d+(\.)?(\d+)?','match','once'))
0 Kommentare
Siehe auch
Kategorien
				Mehr zu Characters and Strings finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


