Hide Forgot
Description of problem: In nano, searches for regular expressions are supported. However, for character classes [:lower:], [:upper:] the results are incorrect. This is while invoking nano with "env LC_CTYPE=C nano ...", or just with "nano ..." (LC_CTYPE="en_US.utf8") Version-Release number of selected component (if applicable): nano-2.5.3-1.fc24.x86_64 How reproducible: Always Steps to Reproduce: 1. Invoke nano with "env LC_ALL=C nano ..." (May want to use a file containing "0 a Z % . 1 b Y # , ✓" for testing) Note: last character in string is unicode check mark. 2. Invoke a search (CTL-w), then switch to a regex search (ALT-r) 3. For the regex, enter "[[:upper:]]" (no-quotes), and press enter Actual results: The search places the cursor on the next letter, lower case, or upper case, regardless. Expected results: The search places the cursor on the next upper case letter. Additional info: The following regex work as expected (incomplete list): [[:digit:]] [^[:digit:]] [[:alpha:]] [^[:alpha:]] [[:print:]] [^[:print:]] The following regex do NOT work as expected (incomplete list): [[:lower:]] [[:upper:]]
You need to enable case-sensitive search by ALT-c to get the expected result. Alternatively, you can can enable case-sensitive search by default: echo set casesensitive >> ~/.nanorc
Thanks for the info. While it is good that there are 2 alternative ways to do a case sensitive search that do work, the regular expression way should also work, or it should be documented that it does not work.
As I understand it, the Reg Exp and Case Sens options are independent of each other. You can choose: 1) plain-text case-insensitive search 2) plain-text case-sensitive search 3) regex-based case-insensitive search 4) regex-based case-sensitive search All the combinations seem to work as expected. If you find it confusing, please report it directly to the upstream developers, preferably with a patch improving the current documentation.
Thanks for the clarification. So the "regular expressions" in nano are actually Franken-sort-of-regular-expressions. I'll work on some verbage for upstream.
The behavior of nano is the same as "grep -i" - so this is not a bug - and nano does not have Franken-regular-expressions - even if they are confusing sometimes.