find expression within {}
6 ビュー (過去 30 日間)
古いコメントを表示
Ajay krishna Vasanthakumar
2020 年 8 月 20 日
編集済み: Ajay krishna Vasanthakumar
2020 年 8 月 20 日
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 件のコメント
Rik
2020 年 8 月 20 日
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?
採用された回答
Rik
2020 年 8 月 20 日
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で String Parsing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!