garabik/grc

case insensitivity needed

1manfactory opened this issue · 1 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

lnxbil commented

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.