Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

case insensitivity needed #221

Open
1manfactory opened this issue Nov 8, 2022 · 2 comments
Open

case insensitivity needed #221

1manfactory opened this issue Nov 8, 2022 · 2 comments

Comments

@1manfactory
Copy link

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
Copy link

lnxbil commented Aug 11, 2023

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.

@PBudmark
Copy link

PBudmark commented Jan 1, 2025

Python Regular expressions from 3.6 supports an extension notation applicable to this issue, using (?i:...) to ignore case in ...

As stated in the issue, check for error in all cases, coloring the line yellow, with word error/Error/ERROR in red
It seems that the (?i:...) group is not counted, so an additional group is required to match 2:nd color
The first color in color list refers th the whole matched string, and following colors refer to the individual groups

# Check for error in all cases, coloring the line yellow, with word error/Error/ERROR in red
regexp=^.+(?i:(error)).*$
colours=yellow, red
=======

Source https://docs.python.org/dev/library/re.html#regular-expression-syntax, part (?aiLmsux-imsx:...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants