how to find a exact word in a string?
Mostra commenti meno recenti
Hi I am trying to return the value that matches with a given word in a string...
str = 'talk talking people talk talking talk'
if this is my string and I am trying to return how many times 'talk' shows up in the string, what should I do?
this is my code so far but it also returns 'talking'... is there any other way to fix this?
find = strfind(str, 'talk')
Risposte (1)
Walter Roberson
il 5 Lug 2020
length(regexp(str, '\<talk\>'))
4 Commenti
gmltn1212
il 5 Lug 2020
madhan ravi
il 5 Lug 2020
['\<' word1 '\>'] % in expression of sir Walters code
Walter Roberson
il 5 Lug 2020
Madhan is correct, ['\<' word1 '\>'] as the pattern
Chandan
il 11 Ott 2023
Thanks you, It works perfect
Categorie
Scopri di più su Characters and Strings in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!