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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:30:55+00:00 2026-05-16T10:30:55+00:00

How do I use the inline modifiers instead of RegexOptions.Option ? For example: Regex

  • 0

How do I use the inline modifiers instead of RegexOptions.Option?

For example:

Regex MyRegex = new Regex(@"[a-z]+", RegexOptions.IgnoreCase);

How do I rewrite this using the inline character i?

http://msdn.microsoft.com/en-us/library/yd1hzczs.aspx

  • 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-16T10:30:56+00:00Added an answer on May 16, 2026 at 10:30 am

    You can use inline modifiers as follows:

    // case insensitive match
    Regex MyRegex = new Regex(@"(?i)[a-z]+");  // case insensitive match
    

    or, inverse the meaning of the modifier by adding a minus-sign:

    // case sensitive match
    Regex MyRegex = new Regex(@"(?-i)[a-z]+");  // case sensitive match
    

    or, switch them on and off:

    // case sensitive, then case-insensitive match
    Regex MyRegex = new Regex(@"(?-i)[a-z]+(?i)[k-n]+");
    

    Alternatively, you can use the mode-modifier span syntax using a colon : and a grouping parenthesis, which scopes the modifier to only that group:

    // case sensitive, then case-insensitive match
    Regex MyRegex = new Regex(@"(?-i:[a-z]+)(?i:[k-n]+)");
    

    You can use multiple modifiers in one go like this (?is-m:text), or after another, if you find that clearer (?i)(?s)(?-m)text (I don’t). When you use the on/off switching syntax, be aware that the modifier works till the next switch, or the end of the regex. Conversely, using the mode-modified spans, after the span the default behavior will apply.

    Finally: the allowed modifiers in .NET are (use a minus to invert the mode):

    x allow whitespace and comments
    s single-line mode
    m multi-line mode
    i case insensitivity
    n only allow explicit capture (.NET specific)

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

Sidebar

Related Questions

While it would be very convenient to use inline functions at some situations, Are
I use a GridView control which uses paging and inline editing. I am not
I use a PHP script to validate video requests before serving them. This script
If I create a dll called xaisoft.dll like this: Using System; Using System.Reflection; [assembly:AssemblyVersion(1.0.0.0)]
'''use Jython''' import shutil print dir(shutil) There is no, shutil.move, how does one move
Use case: A does something on his box and gots stuck. He asks B
Use case: 3rd party application wants to programatically monitor a text file being generated
We use a data acquisition card to take readings from a device that increases
I use Firebug and the Mozilla JS console heavily, but every now and then
I use rsync to synchronize files to Windows clients in a server agnostic way.

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.