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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:08:46+00:00 2026-05-17T20:08:46+00:00

I am working with ASP.NET and need to manage with a string typed by

  • 0

I am working with ASP.NET and need to manage with a string typed by the user in order to extract some information. The user enters a normal text, words and numbers, but sometimes he may type a mathematical expression in MATHML, these expressions are always an xml string enclosed by the tag.
I want to extract from the typed text every math segment.
For example, let’s consider the user typed this text:

string input = "My name is Dorry and here is a math expression: <math>---some math1---</math> ah, there is another expression: <math>---some math2---</math> and do not forget this too <math>---some math3---</math>.".

Well, The first regex solution I came up with is this:

string pattern1 = @"\<math(.+)\<\/math\>";

To get matches I obviousely use:

Regex r = new Regex(pattern1, RegexOptions.IgnoreCase);
string[] res = r.Matches(input);

And it seemd working, too bad, it does not because this expression, instead of getting me an array (using Reges.Matches) filled with three strings (“—some math1—“, “—some math2—“, “—some math3—“); it gets me an array with one element only: “—some math1— ah, there is another expression: —some math2— and do not forget this too —some math3—“. Can you see? it takes the first and the last and merges everything in the middle WITHOUT CARING of some other or elements in the way!

Well, I suppose this is a well known issue about regular expressions; is there a solution? how to tell the regex engine to be a little more… aware?

Thank you very much in advance.

  • 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-17T20:08:47+00:00Added an answer on May 17, 2026 at 8:08 pm

    Give this a go..

    string pattern1 = @"\<math[\s\S]*?<\/math\>";
    Regex r = new Regex(pattern1, RegexOptions.IgnoreCase);
    MatchCollection res = r.Matches(input);
    

    Nick

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

Sidebar

Related Questions

I am working with asp.net website project that some of pages need authentication. I
I'm working on an ASP.NET/C# app. I have 2 text boxes and I need
I'm working on an asp.net application which uses Lucene.net I need to highlight the
I'm working in ASP.NET c# application. I came to a part where I need
I'm working with a intranet website written in ASP.NET and need to be able
I am working on solution for Sharepoint 2010 c# and asp.net and need to
I am working on an ASP.NET MVC application where I need to export data
I am working on a ASP.NET app and i have a need to post
I am working on an ASP.NET website with sql server 2008 R2. i need
I am working on an old ASP web app (not .net) and I need

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.