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

  • SEARCH
  • Home
  • 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 7491495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:03:54+00:00 2026-05-29T16:03:54+00:00

When learning regular expressions, I once saw the following four examples. How can I

  • 0

When learning regular expressions, I once saw the following four examples. How can I understand their differences?

/ABC (?i:s) XYZ/
/ABC (?x: [A-Z] \.?  \s )?XYZ/
/ABC (?ix: [A-Z] \.?  \s )?XYZ/
/ABC (?x-i: [A-Z] \.?  \s )?XYZ/i

What do the i and x flags mean?

  • 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-29T16:03:55+00:00Added an answer on May 29, 2026 at 4:03 pm

    Those are very straightforward. A quick look at the documentation would answer your questions. You might also find YAPE::Regex::Explain useful.

    $ perl -MYAPE::Regex::Explain -e'
       print YAPE::Regex::Explain->new($_)->explain
          for 
             qr/ABC (?i:s) XYZ/,
             qr/ABC (?x: [A-Z] \.?  \s )?XYZ/,
             qr/ABC (?ix: [A-Z] \.?  \s )?XYZ/,
             qr/ABC (?x-i: [A-Z] \.?  \s )?XYZ/i;
    '
    

    The regular expression:
    
    (?-imsx:ABC (?i:s) XYZ)
    
    matches as follows:
    
    NODE                     EXPLANATION
    ----------------------------------------------------------------------
    (?-imsx:                 group, but do not capture (case-sensitive)
                             (with ^ and $ matching normally) (with . not
                             matching \n) (matching whitespace and #
                             normally):
    ----------------------------------------------------------------------
      ABC                      'ABC '
    ----------------------------------------------------------------------
      (?i:                     group, but do not capture (case-
                               insensitive) (with ^ and $ matching
                               normally) (with . not matching \n)
                               (matching whitespace and # normally):
    ----------------------------------------------------------------------
        s                        's'
    ----------------------------------------------------------------------
      )                        end of grouping
    ----------------------------------------------------------------------
       XYZ                     ' XYZ'
    ----------------------------------------------------------------------
    )                        end of grouping
    ----------------------------------------------------------------------
    

    The regular expression:
    
    (?-imsx:ABC (?x: [A-Z] \.?  \s )?XYZ)
    
    matches as follows:
    
    NODE                     EXPLANATION
    ----------------------------------------------------------------------
    (?-imsx:                 group, but do not capture (case-sensitive)
                             (with ^ and $ matching normally) (with . not
                             matching \n) (matching whitespace and #
                             normally):
    ----------------------------------------------------------------------
      ABC                      'ABC '
    ----------------------------------------------------------------------
      (?x:                     group, but do not capture (disregarding
                               whitespace and comments) (case-sensitive)
                               (with ^ and $ matching normally) (with .
                               not matching \n) (optional (matching the
                               most amount possible)):
    ----------------------------------------------------------------------
        [A-Z]                    any character of: 'A' to 'Z'
    ----------------------------------------------------------------------
        \.?                      '.' (optional (matching the most amount
                                 possible))
    ----------------------------------------------------------------------
        \s                       whitespace (\n, \r, \t, \f, and " ")
    ----------------------------------------------------------------------
      )?                       end of grouping
    ----------------------------------------------------------------------
      XYZ                      'XYZ'
    ----------------------------------------------------------------------
    )                        end of grouping
    ----------------------------------------------------------------------
    

    The regular expression:
    
    (?-imsx:ABC (?ix: [A-Z] \.?  \s )?XYZ)
    
    matches as follows:
    
    NODE                     EXPLANATION
    ----------------------------------------------------------------------
    (?-imsx:                 group, but do not capture (case-sensitive)
                             (with ^ and $ matching normally) (with . not
                             matching \n) (matching whitespace and #
                             normally):
    ----------------------------------------------------------------------
      ABC                      'ABC '
    ----------------------------------------------------------------------
      (?ix:                    group, but do not capture (case-
                               insensitive) (disregarding whitespace and
                               comments) (with ^ and $ matching normally)
                               (with . not matching \n) (optional
                               (matching the most amount possible)):
    ----------------------------------------------------------------------
        [A-Z]                    any character of: 'A' to 'Z'
    ----------------------------------------------------------------------
        \.?                      '.' (optional (matching the most amount
                                 possible))
    ----------------------------------------------------------------------
        \s                       whitespace (\n, \r, \t, \f, and " ")
    ----------------------------------------------------------------------
      )?                       end of grouping
    ----------------------------------------------------------------------
      XYZ                      'XYZ'
    ----------------------------------------------------------------------
    )                        end of grouping
    ----------------------------------------------------------------------
    

    The regular expression:
    
    (?i-msx:ABC (?x-i: [A-Z] \.?  \s )?XYZ)
    
    matches as follows:
    
    NODE                     EXPLANATION
    ----------------------------------------------------------------------
    (?i-msx:                 group, but do not capture (case-insensitive)
                             (with ^ and $ matching normally) (with . not
                             matching \n) (matching whitespace and #
                             normally):
    ----------------------------------------------------------------------
      ABC                      'ABC '
    ----------------------------------------------------------------------
      (?x-i:                   group, but do not capture (disregarding
                               whitespace and comments) (case-sensitive)
                               (with ^ and $ matching normally) (with .
                               not matching \n) (optional (matching the
                               most amount possible)):
    ----------------------------------------------------------------------
        [A-Z]                    any character of: 'A' to 'Z'
    ----------------------------------------------------------------------
        \.?                      '.' (optional (matching the most amount
                                 possible))
    ----------------------------------------------------------------------
        \s                       whitespace (\n, \r, \t, \f, and " ")
    ----------------------------------------------------------------------
      )?                       end of grouping
    ----------------------------------------------------------------------
      XYZ                      'XYZ'
    ----------------------------------------------------------------------
    )                        end of grouping
    ----------------------------------------------------------------------
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Today, I am learning regular expressions =D I understand some basics, like \d+ matches
I've been learning regular expressions for the last few days and I've been stumbled
I'm learning regular expressions and want to help me to create a regular expression
I'm trying my hand in learning Regular Expressions in Oracle ( rather, my first
I am stumped by this one. I am just learning regular expressions and cannot
I've set myself a somewhat ambitious first task in learning regular expressions (and one
I'm learning about regular expressions and have one question; the answer will help me
I'm learning about regular expressions for a script I will be writing down the
Does anyone have some good resources on learning more advanced regular expressions I keep
I am learning regular expressions and I am trying to create one that will

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.