regex replace whole word
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Stephen23
le 1 Juin 2018
Modifié(e) : Stephen23
le 1 Juin 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 commentaires
Stephen23
le 1 Juin 2018
@Bardo: you should accept your answer, if it resolves your original question.
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Characters and Strings dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!