MATLAB: Finding a character in a string

hashtag strfind strread

so I have the following line of code:
hashtag=lower(input('Which hashtag would you like information on?','s'));
This prompts the user to input a hashtag, like say '#helloworld'. However, the program runs even without the user putting the hashtag. So it runs even if they only input "helloworld", which presents problems for me later on. How can I get the code to stop reading and present an error message if there is no hashtag symbol in the user's input? Apparently the # character means something in matlab as well which is causing me problems.
I have this so far but it seems not to work:
if k=(strfind(hashtag,'#')))
error('Please include the hashtag')
end

Best Answer

using start anchor with regexp will ensure that you '#' as the first character of you input string.
hashtag=lower(input('Which hashtag would you like information on?','s'));
if(isempty(regexp(hashtag,'^#','once')))
error('Please include the hashtag')
end