Search for a string within a string

1 view (last 30 days)
Joshitha Giridhar
Joshitha Giridhar on 12 Jan 2022
Edited: KSSV on 12 Jan 2022
Need to search for a specific string inside a longer string and return the string and its position

Answers (1)

KSSV
KSSV on 12 Jan 2022
Edited: KSSV on 12 Jan 2022
Read about the function strfind.
str = 'Need to search for a specific string inside a longer string and return the string and its position' ;
idx = strfind(str,'string')
idx = 1×3
31 54 76

Categories

Find more on Characters and Strings in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!