Effacer les filtres
Effacer les filtres

strrep with replacing precise word and no ' ' explicit in code

3 vues (au cours des 30 derniers jours)
Dominique Joubert
Dominique Joubert le 19 Sep 2018
Commenté : Walter Roberson le 19 Sep 2018
i have an array in a loop:
use{i,1}=strrep(use{i,1},statename{j,1},xx{1,j})
the idea is to find precise statenames and repacle them with xx
but its doing parts.
how do i use the lookbefoe and after idea here, with no ' 'in the code?
DJ

Réponse acceptée

Walter Roberson
Walter Roberson le 19 Sep 2018
Do not use strrep for this: use regexprep with lookaround operators.
  2 commentaires
Dominique Joubert
Dominique Joubert le 19 Sep 2018
Modifié(e) : Stephen23 le 19 Sep 2018
use{i,1}=regexprep(use{i,1},['(?<=[^a-zA-Z,0-9])',statename{j},'(?=[^a-zA-Z,0-9])'],xx{1,j});
Walter Roberson
Walter Roberson le 19 Sep 2018
Are you sure comma to be part of the list? Those are literal comma not range separators.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical 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!

Translated by