ack2 icon indicating copy to clipboard operation
ack2 copied to clipboard

Improve --smart-case handling of meta-characters

Open timgimyee opened this issue 7 years ago • 5 comments

For #670.

Ignore uppercase characters in regex meta-characters, character escapes, and other constructs. For example, --smart-case should see all lowercase here:

ack --smart-case '--s\x6Dart\Wcas\N{LATIN SMALL LETTER E}'

On the other hand, it will now see uppercase "M" and "E" here:

ack --smart-case '--s\115art-cas\x{0045}'

timgimyee avatar Oct 19 '18 02:10 timgimyee

Thanks, this could be very useful.

Can you tell us more about this? How it's working? What version of Perl is it requiring?

petdance avatar Oct 19 '18 02:10 petdance

Before you make more changes, can we discuss this a bit please? I don't want you to make changes that I might not be able to take. Also, we should be looking at this on ack3 before ack2. ack2 might never get another release.

petdance avatar Oct 19 '18 20:10 petdance

Works by replacing/removing all backslashed escapes/sequences before checking if all lowercase. Requires 5.10 since it uses named captures ($+{capture}, $+{escape}, $+{octal}). Switch to $1, $2, etc... if earlier versions of Perl are required.

timgimyee avatar Oct 23 '18 00:10 timgimyee

This has been fixed in ack3. It won't be fixed in ack2 because there won't be more releases of ack2.

petdance avatar Jul 05 '19 02:07 petdance

You've taken a very different approach to your fix than what I implemented in ack3. Would you please look at my ack3 implementation and let me know if you see anything that I might have missed?

petdance avatar Jul 05 '19 02:07 petdance