Find string with options (*)
Mostrar comentarios más antiguos
Hi,
I have a cell of strings that I want to see if any of them match a certain string pattern. The string pattern can be something like 'Object(1)=' or Object(123)='. So basically 'Object(*)=' where the asterisk represents a number. Is there a function in Matlab that has a feature that can search strings like that?
Horace
Respuesta aceptada
Más respuestas (1)
Azzi Abdelmalek
el 30 de Mayo de 2013
Editada: Azzi Abdelmalek
el 30 de Mayo de 2013
s='123 sdd5 Object(1)= 25 333sss'
idx=strfind(s,'Object(1)=')
%or
k=123
pattern=sprintf('Object(%d)=',k)
s='123 sdd5 Object(123)= 25 333sss'
idx=strfind(s,pattern)
2 comentarios
Horace Lai
el 30 de Mayo de 2013
Azzi Abdelmalek
el 30 de Mayo de 2013
idx=regexp(s,'Object\(\d*\)=')
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!