Find location of exact string
Mostrar comentarios más antiguos
Using this line fo code to find "Sine Delta 2" in my xml file which also contains "Cosine Delta 2" and the code returns locaion for both instead of just for "Sine".
How do i return location of the exact string?
row_idx_SineDelta2 = find(~cellfun('isempty',strfind(data,'sine delta 2')))
1 comentario
Tejashree Pawar
el 12 de Mzo. de 2021
Respuesta aceptada
Más respuestas (1)
Jorg Woehl
el 11 de Mzo. de 2021
Editada: Jorg Woehl
el 11 de Mzo. de 2021
Starting with R2020b, you can use pattern with strfind, which allows you to only find matches if they are preceded by a nonletter character (i.e. if the search string starts a new word):
pat = letterBoundary + 'sine delta 2';
strfind(data, pat)
Note that this is case-sensitive; in your code you are searching for 'sine delta 2', but you mention 'Sine Delta 2' in your introduction...
2 comentarios
Tejashree Pawar
el 11 de Mzo. de 2021
Jorg Woehl
el 11 de Mzo. de 2021
Yes, I'll add it as a separate answer...
Categorías
Más información sobre Characters and Strings en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!