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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:32:26+00:00 2026-05-28T04:32:26+00:00

Hi i was trying to filter a large of text file using Regex.Split with

  • 0

Hi i was trying to filter a large of text file using Regex.Split with about more than 20 of string patterns i need to use but the outcome is not correct and there are so many empty strings.

below is my code

string[] tmp = Regex.Split(originalString, @"(LINE|3DFACE|3DSOLID|ARC|ATTDEF|ATTRIB|BODY|CIRCLE|DIMENSION|ELLIPSE|HATCH|HELIX|IMAGE|INSERT|LEADER|LIGHT||LWPOLYLINE|MLINE|MLEADER|MLEADERSTYLE|MTEXT|OLEFRAME|OLE2FRAME|POINT|POLYLINE|RAY|REGION|SECTION|SEQEND|SHAPE|SOLID|SPLINE|SUN|SURFACE|TABLE|TEXT|TOLERANCE|TRACE|UNDERLAY|VERTEX|VIEWPORT|WIPEOUT|XLINE)");

if i only use about 5 of them then the outcome is able to do exactly as i need, is there any limit for regex.split for string patterns?

EDIT 1

THANKS TO @MRAB

here is the code for actually running working and right output

        string fileName = textBox1.Text;
        var stopwatch = new System.Diagnostics.Stopwatch();
        stopwatch.Start();
        TextReader sr = new StreamReader(fileName);
        string originalString = sr.ReadToEnd();
        sr.Close();
        string[] tmp = Regex.Split(originalString, @"(3DFACE|3DSOLID|ACAD_PROXY_ENTITIY|ARC|ATTDEF|ATTRIB|BODY|CIRCLE|DIMENSION|ELLIPSE|HATCH|HELIX|IMAGE|INSERT|LEADER|LIGHT|LWPOLYLINE|MLINE|MLEADERSTYLE|MLEADER|MTEXT|OLEFRAME|OLE2FRAME|POINT|POLYLINE|RAY|REGION|SEQEND|SHAPE|SOLID|SPLINE|SUN|SURFACE|TABLE|TEXT|TOLERANCE|TRACE|UNDERLAY|VERTEX|VIEWPORT|WIPEOUT|XLINE|LINE)");
        List<string> result = new List<string>();


        for (var i = 1; i < tmp.Count() - 1; i += 2)
        {

            result.Add(tmp[i] + tmp[i + 1]);
        }
  • 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-28T04:32:26+00:00Added an answer on May 28, 2026 at 4:32 am

    You’re using the static Split method of the Regex class. There’s also a Split method on Regex instances, for example:

    new Regex(@"(LINE|3DFACE|3DSOLID)").Split(originalString, 5, 0);
    

    Your code contains this in the regex:

    "LIGHT||LWPOLYLINE"
    

    which looks like a mistake to me.

    You should also note that when you have a regex like this:

    "MLEADER|MLEADERSTYLE"
    

    and a string like this:

    "MLEADERSTYLE"
    

    it will match "MLEADER" because that occurs earlier in a regex. Where a short literal occurs as a prefix of a longer literal, put the longer one earlier.

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

Sidebar

Related Questions

I'm trying to filter webserver log files using grep. I need to output all
I'm currently trying to filter a text-file which contains words that are separated with
I have a really large excel file and i need to delete about 20,000
I am trying to filter items with a stored procedure using like . The
I'm trying to filter some XML in JavaScript using E4X and have some specific
I'm trying to filter by a list of values using the criteria API. I
I am attempting to Filter a large list of tabular data with text keyup.
I'm trying to use oprofile to record cache misses in a large realtime app:
I'm trying to extract a set of data from some (large) text files. Basically,
I'm trying to filter out invalid user inputs in a small C++ program using

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.