Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4601404
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:49:12+00:00 2026-05-21T23:49:12+00:00

How can I autogenerate a case insensitive REGEXP for a string that may have

  • 0

How can I autogenerate a case insensitive REGEXP for a string that may have the case following variations:
‘ENTI’, ‘Enti’

I got this so far but it looks clumsy,

entity_type = 'Enti'
prefix = 'E'
for char in entity_type[1:]:                          
    logs_prefix += '[' + char.upper() + char.lower() + ']'
print logs_prefix

>>>'E[Nn][Tt][Yy]'

My goal is to initially discover the list of active logs (the rotated ones will be ending with a timestamp) which start with a given case insensitive sequence, so I can

regexp_filters = logs_prefix + '_A.out'
command = "ssh %(user)s@%(ip)s 'cd %(source_path)s; ls -t %(regexp_filters)s'" % locals()

and generate different rsync expressions for a range of hosts.
Ignore the exclude, its made of several –excludes witholder, crashed ‘*_A.out’ logs

sync = "rsync -e ssh -a %(remote_rsync_binary)s --compress=9 -pgtov %(excluded_expression)s %(filters_expression)s --exclude='*' %s(user)@%(ip)s:%(source_path)s%(file_filter)s %(target_path)s" % locals()

Minor question, how to easily enclose a string/char with other chars,
in this case:
[char]

EDIT :
Found a cleaner solution, is there a better way?

for char in entity_type[1:]:
    prefix += "[%s]" % "%s%s" % (char.upper(), char.lower() ) 

EDIT2: (improvement)
as @eyquem wrote,

prefix + ''.join( "[%s%s]" % (char.upper(), char.lower() for char in entity_type[1:])
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T23:49:13+00:00Added an answer on May 21, 2026 at 11:49 pm

    Try this:

    reEnti = re.compile('ent[iy]',re.IGNORECASE)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I have a datagridview that will autogenerate a textbox instead of a
I see that the data is there when I autogenerate. I can't seem to
I have a large .sql file of tables -- is there software that can
Can somebody point me to a resource that explains how to go about having
Can you cast a List<int> to List<string> somehow? I know I could loop through
Can a LINQ enabled app run on a machine that only has the .NET
I have a photo viewer page that I need to make work with varying
I have a msgClass looking like this for all my appMessages ( using mvvm
Can anyone (maybe an XSL-fan?) help me find any advantages with handling presentation of
can you recommend some good ASP.NET tutorials or a good book? Should I jump

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.