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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:06:11+00:00 2026-05-25T15:06:11+00:00

I have a String needs to be split by semi-colon. The easiest way to

  • 0

I have a String needs to be split by semi-colon. The easiest way to go is [^;]+. By using this, every semi-colon in the string will be used as a delimiter.

However, in our string, there are some “&” that we do not want to include that ; as a delimiter.

For example, a String

abcd;efg;hij&kl;mn

The expected result would be abcd, efg, hij&kl, mn

Can some one help me to solve this problem?

  • 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-25T15:06:11+00:00Added an answer on May 25, 2026 at 3:06 pm

    If you want to match everything outside of “real ;s”:

    (?:&|[^;])+
    

    would work. Or (?:&\w+;|[^;])+ if more than just & entities are to be expected.

    If your regex engine supports split operations, perhaps this regex (matching semicolons only if not preceded by &amp) is also a good idea

    (?<!&amp);
    

    To also allow other entities like above, (?<!&\w+); can be used if your regex implementation supports indefinite repetition inside lookbehind assertions. Most don’t, though, .NET being an exception.

    In Python:

    >>> import re
    >>> re.findall("(?:&amp;|[^;])+", "abcd;efg;hij&amp;kl;mn")
    ['abcd', 'efg', 'hij&amp;kl', 'mn']
    >>> re.split("(?<!&amp);", "abcd;efg;hij&amp;kl;mn")
    ['abcd', 'efg', 'hij&amp;kl', 'mn']
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string aa:bb::cc:yy:zz which needs to be split in such a way
I'm using this method to split some text: String[] parts = sentence.split([,\\s\\-:\\?\\!\\«\\»\\'\\´\\`\\\\\.\\\\\\/]); Which will
I have a string which needs to be split by three underscore characters. An
I have a string of the form foo-bar-1.23-4, and I need to split at
I have a long string (multiple paragraphs) which I need to split into a
I have a string dependency property (SearchText), when updated, needs to update a collection
I have a arbitrarily large string of text from the user that needs to
I have a piece of C# code that needs to convert a string array
I need to be able to split an input String by commas, semi-colons or
I have an ASP.NET application which needs to search a VARCHAR(20) column using lists

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.