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 916419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:02:57+00:00 2026-05-15T18:02:57+00:00

In python, I’m compiling a regular expression pattern like so: rule_remark_pattern = re.compile(‘access-list shc-[(in)(out)]

  • 0

In python, I’m compiling a regular expression pattern like so:

rule_remark_pattern = re.compile('access-list shc-[(in)(out)] [(remark)(extended)].*')

I would expect it to match any of the following lines:

access-list shc-in remark C883101 Permit http from UPHC outside to Printers inside
access-list shc-in extended permit tcp object-group UPHC-Group-Outside object-group PRINTER-Group-Inside object-group http-https 
access-list shc-out remark C890264 - Permit (UDP 123) from UPHC-Group-Inside to metronome.usc.edu
access-list shc-out extended permit udp object-group UPHC-Group-Inside host 68.181.195.12 eq ntp 

Unfortunately, it doesn’t match any of them. However, if I write the regular expression as:

rule_remark_pattern = re.compile('access-list shc-in [(remark)(extended)].*')

It matches the first 2 just fine.

Similarly, if I write:

rule_remark_pattern = re.compile('access-list shc-out [(remark)(extended)].*')

It matches the last 2.

Anybody know what’s going on here?

  • 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-15T18:02:58+00:00Added an answer on May 15, 2026 at 6:02 pm

    That’s mainly because you completely mis-understood how “defining alternatives” works in regular expressions:

    access-list shc-(in|out) (remark|extended).*
    

    Your attempt creates character classes. Every character in a character class stands on its own, and the class itself really only matches a single character from the allowed list. So your try:

    [(in)(out)]

    really is the same as

    [intou(())]

    which actually is the same as [intou()] because repeated characters in a character class are ignored.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Python regular expression I have a string that contains keywords but sometimes the keywords
Python beginner here, I have a list of lists and want to refer to
Python allows aliasing of imports, through ...as <ALIAS> clauses in the import statement, like
Python's paster serve app.ini is taking longer than I would like to be ready
Python is installed in a directory all users have full access to, but when
Python-Markdown includes features like escaping of raw HTML that are obviously intended to make
Python docs says that slicing a list returns a new list. Now if a
Python is installed in a local directory. My directory tree looks like this: (local
python manage.py flush removes data from the entire project. I would like to be
Python's access to environment variables does not accurately reflect the operating system's view of

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.