Problem with editor search in R2016b

I switched to R2016b last month when I got a new Windows 10 Pro machine, and have noticed a problem with the editor search function that may or may not be related. If I use Ctrl+F in the Editor window to search for a phrase that includes punctuation, such as
polyfit(
it returns no hits, even though the following search does,
polyfit
Similarly no hits for the following string which is in the .m file,
.Properties.UserData.
But it can find
Properties
The problem seems to be inconsistent (sometimes I can search for strings containing periods or spaces, sometimes I can't, for example). Any ideas how to fix this?

7 Comments

Which operating system are you using?
Are you talking about the Find functionality (Ctrl+F) in the Navigate area under Editor tab?
KAE
KAE on 8 Mar 2017
Edited: KAE on 8 Mar 2017
Walter - I am using Windows 10 Pro.
Prannay - Yes, Ctrl+F within the Editor tab is giving me this problem.
[Sorry for the delay! I updated my question based on your comments. This inconsistent issue persists even though I have restarted many times since posting: for example a search for "text(" just failed but "text" succeeded (ignore the quotes).]
I just tested in Windows 10 with R2016b, and I do not observe this.
Question: is it possible that you are using UTF-8 encoded .m files? Is your system's Region set to something other than English? Do you have some characters in your .m file that do not fit within the usual English character set, char(32) to char(126) ?
[Here is how to find out what region a Windows machine is set to, also see here, and here are suggestions on how to find out the encoding]. My region is set to English/United States. I am not sure how to check if I am using UTF-8 encoded .m files or to look for non-usual characters, but I will say I create my .m files in the Matlab editor and they are nothing fancy, just some file reading commands and arithmetic. I download files from the File Exchange - could those be UTF-8? Is the following a confirmation that I am not using UTF-8 encoded .m files?
feature('DefaultCharacterSet')
ans = windows-1252
@KAE: you could use Notepad++: its "Encoding" menu states what file encoding is used (and lets you change it).
KAE
KAE on 9 Mar 2017
Edited: KAE on 10 Mar 2017
Indeed UTF-8 is marked on the Encoding menu when I opened an .m file in Notepad++! I am confused how it could be UTF-8 since here it says "file encoding is determined by editors, such as MATLAB editor or Notepad, and most editors use the encoding specified by the user default locale setting. " [However see Answer below: the issue is that the "Whole Word" checkbox in the Editor search must be unchecked for strings beginning/ending with punctuation.]

Sign in to comment.

 Accepted Answer

Which (if any) of the three checkboxes titled "Match case", "Whole word", and "Wrap around" at the bottom of the Find & Replace dialog are selected?
What happens when you toggle those checkboxes in the eight possible combinations and repeat the process of trying to find "polyfit(" and ".Properties.UserData." in the file?

3 Comments

KAE
KAE on 9 Mar 2017
Edited: KAE on 9 Mar 2017
All 3 checkboxes were checked. When I unchecked "Whole Word" I was able to find "polyfit(" and ".Properties.UserData." Is that expected behavior? I don't remember this being necessary in early versions of Matlab but then again I can't confirm whether I had that box checked.
I'm not completely sure what "Whole Word" counts as a word, and it's not described in the documentation for that functionality. My guess is that it is a block of characters x for which isstrprop(x, 'alpha') returns all true values or something to that effect. If that is the case I'm not really surprised that a punctuation character (either ( or .) interferes with finding a whole word.
If you want to confirm that I described above, it would be worth a question to Technical Support and/or feedback to the documentation staff for the documentation page about finding and replacing in the Editor asking to clarify those three checkboxes. [You can select the No button on the "Was this topic helpful?" question at the end of the documentation page to send your feedback right to the documentation staff.]
Technical support was very helpful and said, "Here is the current checking system that a "Whole word" search does:
1. Checks if the first character is a letter or digit or underscore.
2. Checks if the last character is a letter or digit or underscore.
3. Checks if the character after the last is letter or digit or underscore.
Note that queries like yours that involve punctuation are not handled as specific cases."
So the workaround is to keep the "Whole Word" checkbox unchecked, which for me is worth it.

Sign in to comment.

More Answers (0)

Categories

Tags

Asked:

KAE
on 2 Mar 2017

Edited:

KAE
on 10 Mar 2017

Community Treasure Hunt

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

Start Hunting!