regex replace whole word
8 ビュー (過去 30 日間)
古いコメントを表示
Hi,
How to change
'v1 = v1a;'
to
'v(1) = v1a;'
using regex or regexrep?
regexprep('v1 = v1a','\bv1\b','v(1)')
apparently does not work.
0 件のコメント
採用された回答
Stephen23
2018 年 6 月 1 日
編集済み: Stephen23
2018 年 6 月 1 日
>> regexprep('v1 = v1a','^([a-z]+)(\d+)','$1($2)')
ans = v(1) = v1a
Hopefully you are not constructing arbitrary strings of code for evaluating!
8 件のコメント
Stephen23
2018 年 6 月 1 日
@Bardo: you should accept your answer, if it resolves your original question.
その他の回答 (1 件)
参考
カテゴリ
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!