MATLAB Answers

Trying to decrypt a message

2 views (last 30 days)
Angie Lee
Angie Lee on 27 Nov 2019
Commented: Angie Lee on 27 Nov 2019
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:
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 ']'.


Sign in to comment.

Accepted Answer

Guillaume on 27 Nov 2019
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 Comment

Sign in to comment.

More Answers (0)

Sign in to answer this question.