grc icon indicating copy to clipboard operation
grc copied to clipboard

case insensitivity needed

Open 1manfactory opened this issue 2 years ago • 2 comments

Hello I want to check for "error", "Error" and "ERROR" in my log files. How can I make the regex case-insensitive. I can't add an "i" to the expression like in other regex installations. I could really need that. Great work regards Juergen

1manfactory avatar Nov 08 '22 09:11 1manfactory

I just had the same problem and wrote a little script to generate the appropriate regular expression for any up/down-case combination:

#!/usr/bin/env ruby

if ARGV.size != 1
  puts "ERROR: Please provide a string"
  exit 1
end

str = ""
ARGV[0].split(//).each do |c|
  str += "[#{c.upcase}#{c.downcase}]"
end

puts str

which does what I needed ...

./updownregexpr Hello
[Hh][Ee][Ll][Ll][Oo]

Maybe it helps.

lnxbil avatar Aug 11 '23 13:08 lnxbil