I have a text file that contains a hidden message with a bunch of random characters in between letters and # symbols that separate each word. Here is the first line of the text:
;,.T234h467e#i`12n390@%f&^%o1@45r1%^m]\a131@t2i*/-o+/1n#i*895n#t$5&&h1/!i@$$s#f18945@i2/le#i98s#c`$%o%^n77*f(=i(*d@!e1*/n--t+/*i1/2a@@l
I need to figure out how to write a single line for my toFind phrase that gathers only the letters and the # symbols. Here is what I have so far:
toFind = '[[a-zA-Z][#]]';
matches = regexp(line,toFind,'match');
This toFind statement finds all of the letters and #'s, but it also keeps a random ']' symbol in there. I'm not sure how to re-write the toFind statement to exclude the ']'.

 採用された回答

Guillaume
Guillaume 2019 年 11 月 27 日

0 投票

tofind = '[a-zA-z#]'
Read the regexp doc and its examples to learn how ranges work.
You may want to add a quantifier to the end of your expression as well.

1 件のコメント

Angie Lee
Angie Lee 2019 年 11 月 27 日
Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

質問済み:

2019 年 11 月 27 日

コメント済み:

2019 年 11 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by