Discard unwanted information from string array

3 ビュー (過去 30 日間)
Raj Tailor
Raj Tailor 2018 年 12 月 2 日
回答済み: Raj Tailor 2018 年 12 月 2 日
Hello Everyone,
I am in need of a help to remove some part of information from the string array.
I have a 8x1 string array with the information shown below,
ans =
8×1 string array
"<img src="https://www.tu-chemnitz.de/tu/termine/image/20219.png" alt="Optimizing application documents">"
"<img src="https://www.tu-chemnitz.de/tu/termine/image/19987.png" alt="Gedächtnis- und Konzentrationstechniken">"
"<img src="https://www.tu-chemnitz.de/tu/termine/image/19973.png" alt="LiT.Workshop: Instruktionsvideos der eigenen Lehre erstellen">"
"<img src="https://www.tu-chemnitz.de/tu/termine/image/20003.png" alt="Flexible Arbeit im Kontext eines digitalen Unternehmens">"
"<img src="https://www.tu-chemnitz.de/tu/termine/image/19876.png" alt="Mit Licht geschossen | 53. Bildpräsentation">"
"<img src="https://www.tu-chemnitz.de/tu/termine/image/20084.png" alt="Splu Experts GmbH: Daniel Düsentrieb meets DIN">"
"<img src="https://www.tu-chemnitz.de/tu/termine/image/20244.png" alt="SIESTA-Lesung">"
"<img src="https://www.tu-chemnitz.de/tu/termine/image/20099.png" alt="Willkommen an Sachsens Schulen! Praktikum – Vorbereitungsdienst – Schuldienst">"
For each string, I need the only information starts after "alt" and text before alt should be discarded
For example, with string 1, I only need information "Optimizing application documents">"
Could you help me by providing guidance on how can I do it?
I have learned about function "regexprep", but I do not know, how to implement it here.

採用された回答

Rik
Rik 2018 年 12 月 2 日
Try something like this:
expr='(.*alt=")';
regexprep(str,expr,'')

その他の回答 (2 件)

dpb
dpb 2018 年 12 月 2 日
Alternatively, there's the new(ish) extractAfter function that was introduced with the new strings class...
>> extractAfter(s,"alt=")
ans =
""Optimizing application documents">"
>>

Raj Tailor
Raj Tailor 2018 年 12 月 2 日
Thank you so much Rik and dpb,
The solution worked for me, much appreciated.

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by