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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:23:05+00:00 2026-06-01T03:23:05+00:00

I have text that starts with (parag1 level=All) as start tag and end with

  • 0

I have text that starts with (parag1 level="All") as start tag and end with (/parag1) as end tag, and between them is text.

How can I with regex in C# check that the user selected text with start tag or end tags?
I use parentheses for tags: (tag)text(/tag)

Example:

(Parag1 level="All")
This is my string1. This is my string2. This is my string3.
(/Parag1) 

The user may select:

(Parag1 level="All")
This is my

Or

level="All")
This is my

Or (this one is does not have the start tag)

is my string1

Or (this one has the start tag with l”) and end tag with ( )

l")
This is my string1. This is my string2. This is my string3.
(

I want to check:

  • Does it start with “start tag” or part of “start tag”?
    Selected text 1 and 2,4 is ok, but 3 is no.

  • Does it end with “end tag” or part of “end tag”?
    Selected text 1,2,3 is no, but 4 is ok.


How can i change my regex patern that include all below text.
pattern :

(<Parag)\d+\s(Level=")\w+(">)

text :

<Parag1 Level="all">

<Parag2 Level="Total">

Parag3 Level="all">

arag4 Level="all">

rag5 Level="all">

ag6 Level="all">

g7 Level="all">

8 Level="all">

 Level="all">

Level="all">

evel="all">

vel="all">

el="all">

l="all">

="all">

="all">

"all">

all">

ll">

l">

">

>

Change regex pattern c#

  • 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-01T03:23:07+00:00Added an answer on June 1, 2026 at 3:23 am

    I know this isn’t a RegEx solution as you requested, but here’s an outside the box idea. Since your example text has some XML-like qualities, have you considered replacing the ( and ) with < and > and parsing it with an XML parser?

    To use this solution though, your text could not have any parenthesis other than the tags, and you would have to replace any illegal characters with their respective escape sequences.

    One other issue you would have to deal with is a root-level tag. If one does not exist, you would have to wrap your original string in one:

    String data = // your string here with all opening and closed tags    
    data = "<root>" + data + "</root>"  //if your data does not have a root tag, if it does, you can omit this
    data = data.Replace('(', '<').Replace(')', '>');
    
    
    XElement element = XElement.Parse(data);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need change background of all text that have two spaces from the start
I have a text string that starts with a number of spaces, varying between
I have a block of text and each word in it, that starts from
i have uitextfield i wan that it should start entering text from top instead
I have a text in EPUB, in this text there's a link that starts
In PostgreSQL I have a text column that contains values representing start and stop
I have a text file that lists any possible problems. It always starts with
I have a text box that is getting autocompleted when the person starts typing
I require a regex that will text that a string starts with one chaecter
In my Java program, I have a text component that can fire events in

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.