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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:11:56+00:00 2026-06-03T19:11:56+00:00

I have the following very simple regex, which matches HTML tags in a string.

  • 0

I have the following very simple regex, which matches HTML tags in a string. I have the case insensitive option set, so that capitalisation of the tags doesn’t matter. However, when the ‘compiled’ option is set, then the ‘IgnoreCase’ option seems to be ignored.

Sample code:

string text = "<SPAN>blah</SPAN><span>blah</span>";
Regex expr1 = new Regex("</*span>", RegexOptions.IgnoreCase);
Regex expr2 = new Regex("</*span>", RegexOptions.IgnoreCase & RegexOptions.Compiled);

MatchCollection result1 = expr1 .Matches(text); 
//gives 4 matches- <SPAN>,</SPAN>,<span> & </span>
MatchCollection result2 = expr2 .Matches(text);
//only gives 2 matches- <span> & </span>

Has anybody got an idea what is 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-06-03T19:11:57+00:00Added an answer on June 3, 2026 at 7:11 pm

    You are using a bitwise AND for your flags, you should be using a bitwise OR.

    This bit:

    RegexOptions.IgnoreCase & RegexOptions.Compiled
    

    Should be:

    RegexOptions.IgnoreCase | RegexOptions.Compiled
    

    Here is a good article on how flags and enumerations work in respect to C#.

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

Sidebar

Related Questions

I have a very simple html page with the following javascript in it $(function()
I have the following very simple code: html <a data-bind=enable: selected() href=http://www.google.com>Click Me</a> javascript
I have the following very simple Ext JS 4 script which is supposed to
I have the following code that does something very simple: visits recursively a tree
I have the following very simple application that compiles and runs fine: EDIT: changed
I have the following very simple class which looks for the last known user
I have got the following very simple code: function init() { var articleTabs =
I have the following PHP code doing a very simple select into a table.
I have the following function which works very well within a $(document).ready(function(){ $('.threadWrapper >
I am trying to write a very thin hypervisor that would have the following

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.