regex replace whole word
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Bardo
am 1 Jun. 2018
Kommentiert: Stephen23
am 1 Jun. 2018
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 Kommentare
Akzeptierte Antwort
Stephen23
am 1 Jun. 2018
Bearbeitet: Stephen23
am 1 Jun. 2018
>> regexprep('v1 = v1a','^([a-z]+)(\d+)','$1($2)')
ans = v(1) = v1a
Hopefully you are not constructing arbitrary strings of code for evaluating!
8 Kommentare
Stephen23
am 1 Jun. 2018
@Bardo: you should accept your answer, if it resolves your original question.
Weitere Antworten (1)
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!