find expression within {}
    5 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    Ajay krishna Vasanthakumar
 am 20 Aug. 2020
  
    
    
    
    
    Bearbeitet: Ajay krishna Vasanthakumar
 am 20 Aug. 2020
            Hello all,
i have to fin {i++;} from the below expression using regexp.can some one help me out?
x = [task_queue[i] > 0 && i<NUM_FLOOR]{i++;}/{a =1;};
i tired using the below regexp
regexp(x,'[^/]\s*{.*}','match')
output : ']{i++;}/{a =1;}'
Thanks,
Ajay
2 Kommentare
  Rik
      
      
 am 20 Aug. 2020
				Although you can do it with regexp, why would you? strfind will do the job here. What do you want to do with the result?
Akzeptierte Antwort
  Rik
      
      
 am 20 Aug. 2020
        You were close: you forgot to make the expression lazy, and you forgot you included the close bracket from the sting when excluding the / matched part.
str='x = [task_queue[i] > 0 && i<NUM_FLOOR]{i++;}/{a =1;};';
a=regexp(str,'[^/]({.*?})','tokens');
a{1}
1 Kommentar
Weitere Antworten (0)
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!

