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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:34:43+00:00 2026-06-17T06:34:43+00:00

I’m using TCPClient to send message (List of arrays) over LAN, so I have

  • 0

I’m using TCPClient to send message (List of arrays) over LAN, so I have separated:

  • array elements with combination: string arr_sep = "[s{p(a)c}e]";
  • list elements with combination: string list_sep = "[n|e|w)";

How to decipher the following string line to List<string[]> using the regex?

string tessst = "abra[s{p(a)c}e]kada[s{p(a)c}e]bra[n|e|w)hel[s{p(a)c}e]oww[s{p(a)c}e]een";

Here is what I tried to do:

        string tessst = "abra[s{p(a)c}e]kada[s{p(a)c}e]bra[n|e|w)hel[s{p(a)c}e]oww[s{p(a)c}e]een";
        List<string[]> splited2 = new List<string[]>();

        if (tessst.Length > 0)
        {
            List<string> splited1 = new List<string>(Regex.Split(tessst, "[^a-zA-Z]+")); //[s{p(a)c}e]

            for (int i = 0; i < splited1.Count; i++)
            {
                splited2.Add(Regex.Split(splited1[i], "[^a-zA-Z]+")); // [n|e|w)
            }
        }
        //splited2  is the result!

Unfortunately, Regex is completely broken – how do I fix it? Is there a better approach maybe?

Expected result:

List<string[]> result = new List<string[]>();
result.Add(new string[]{"abra", "kada", "bra"});
result.Add(new string[]{"hel", "oww", "een"});

EDIT: fix

When I receive the data – I normally limit the bytes to 1024, however that’s not enough to get all 50 entries of List<string[]>!

I increased the number of bytes up to 10000 and now all info goes through LAN! It takes 3499 bytes to serialize 50 string[] of List<string[]>. In the future I will be using up to 900 entries in my List, so it is safe to assume that I will need:

(3499/50)*900 = 63000 bytes to serialize my data!!

the question is – is it safe/secure to send that must data at once? Here is the code that I use to receive:

string message = "";
int thisRead = 0;
int max = 10000; // from 1024 to 10000
Byte[] dataByte = new Byte[max];
using (var strm = new MemoryStream())
{
  thisRead = Nw.Read(dataByte, 0, max);
  strm.Write(dataByte, 0, thisRead);
  strm.Seek(0, SeekOrigin.Begin);

  using (StreamReader reader = new StreamReader(strm))
  {
     message = reader.ReadToEnd();
  }

}
List<string[]> result = new JavaScriptSerializer().Deserialize<List<string[]>>(message );

And that’s to send:

List<string[]> list= new List<string[]>();
list = browser_ex.GetMusicListSer(); // 50 list elements
string text_message = new JavaScriptSerializer().Serialize(list);
MemoryStream Fs = new MemoryStream(ASCIIEncoding.Default.GetBytes(text_message));
Byte[] buffer = Fs.ToArray();
Nw.Write(buffer, 0, buffer.Length); // 3499 bytes

Can I increase the maximum amount of bytes to 100 thousands and forget about this problem once and for all? There should be another solution… i believe.

  • 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-17T06:34:44+00:00Added an answer on June 17, 2026 at 6:34 am

    Instead of reinventing the wheel, use serialization

    You have many alternatives for this (JavaScriptSerializer, DataContractSerializer, DataContractJsonSerializer, BinaryFormatter, SoapFormatter, XmlSerializer).

    List<string[]> list = new List<string[]>();
    list.Add(new string[] { "abra", "kada", "bra" });
    list.Add(new string[] { "hel", "oww", "een" });
    
    string stringToSend = new JavaScriptSerializer().Serialize(list);
    //Send 
    string receivedString = stringToSend;
    List<string[]> result = new JavaScriptSerializer()
                                .Deserialize<List<string[]>>(receivedString);
    

    »EDIT«

    Assuming Nw is NetworkStream, your code can be as simple as like this:

    //Receiver
    StreamReader reader = new StreamReader(Nw);
    while (true)
    {
        List<string[]> result = new JavaScriptSerializer()
                    .Deserialize<List<string[]>>(reader.ReadLine());
    
        //do some work with "result"
    
    }
    
    //Sender
    StreamWriter writer = new StreamWriter(Nw);
    while (true)
    {
        //form your "list" and send
        writer.WriteLine(new JavaScriptSerializer().Serialize(list));
        writer.Flush();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have an array which has BIG numbers and small numbers in it. I
I have thousands of HTML files to process using Groovy/Java and I need to
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text

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.