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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:00:27+00:00 2026-06-14T14:00:27+00:00

I want to split my text by <> characters. Example suppose I have a

  • 0

I want to split my text by <> characters.

Example suppose I have a string

 string Name="this <link> is my <name>";

Now I want to split this so that I have a array of string like

ar[0]="this "
ar[1]="<link>"
ar[2]=" is my "
ar[3]="<name>"

I was trying with split function like

string[] ar=Name.Split('<');

I have also tried

 string[] nameArray = Regex.Split(name, "<[^<]+>");

But this is not giving me

 "<link>"
 and "<name>"

But it is not a good approach.
Can I use regular expression 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-14T14:00:28+00:00Added an answer on June 14, 2026 at 2:00 pm

    This

    Regex r = new Regex(@"(?<=.)(?=<)|(?<=>)(?=.)");
    foreach (var s in r.Split("this_<link>_is_my_<name>"))
    {
        Console.WriteLine(s);
    }
    

    gives

    this_
    <link>
    _is_my_
    <name>
    

    (underscores used for clarity)

    The regex splits on a zero-width point (so it doesn’t remove anything) which is either:

    • preceeded by something and followed by <
    • preceeded by > and followed by something

    The “something” checks are necessary to avoid empty strings at the start or end if your string starts or ends with something in brackets.

    Note something like "<link<link>>" will give you { "<link", "<link>", ">" } so try to make your angle brackets balance.

    If you want empty strings if the string starts with < or ends with > you can use (?=<)|(?<=>). If you want empty strings in the middle when you encounter ><, I think you need to first split on (?=<) and then split all the results on (?<=>) – I don’t think you can do it in one go.

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

Sidebar

Related Questions

I have code like that 010200345 i want split every first three digit please
I want to split a file(suppose a mp3) into four parts.I have tried this
I want to split a string like this: abc//def//ghi into a part before and
lets say I have a string that I want to split based on several
I want to know is there any way to split text like this: 123456789
Suppose I have a string with the text: THIS IS A TEST. How would
I want to split certain text using JavaScript. The text looks like: 9:30 pm
I have a large chunk of text that will come through. I want to
I have the following option text that I want to put into a variable
I have the string like this: String s = word=PS1,p1,p2,p3=q1,q2|word2=PS3,p4,p5,p6=q3; or like this: String

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.