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

  • Home
  • SEARCH
  • 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 1100277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:51:20+00:00 2026-05-17T00:51:20+00:00

Language = C#.NET Anything that is between [STX] and [ETX] must be accepted rest

  • 0

Language = C#.NET

Anything that is between [STX] and [ETX] must be accepted rest of the things must be rejected.

string startparam = "[STX]";
string endparam = "[ETX]";

String str1 = "[STX]some string 1[ETX]"; //Option 1
String str2 = "sajksajsk [STX]some string 2 [ETX] saksla"; //Option 2
String str3 = "[ETX] dksldkls [STX]some string 3 [ETX]ds ds"; //Option 3
String str4 = "dksldkls [STX]some string 4.1[ETX]ds ds [STX] some string 4.2[ETX] jdskjd"; //Option 4

/* the various strings can be appended and converted to a single 
   string using string builder or treat them as different strings*/

ProcessString (string str , string startparam , string endparam)
{
   //What To Write here using RegEX or String Functions in c#

}

/* The output after passing these to a ProcessString () */     
/* Append Output To a TextBox or Append it to a String using For Loop.*/

/* Output Required */

some string 1 
some string 2
some string 3
some string 4.1 
some string 4.2

=============================================================================

EDIT 2

Language = C#

string str = "
[STX]some string 1[ETX]
sajksajsk [STX]some string 2 [ETX] saksla
[ETX] dksldkls [STX]some string 3 [ETX]ds ds
dksldk[STX]ls [STX]some st[ETX]ring 4.1[ETX]ds ds [STX]some string 4.2[ETX] jdskjd";

How can i get the same output if the string array is one single string

/* output */
some string 1 
some string 2
some string 3
some string 4.1 
some string 4.2


/*case 1*/ 
the above string can be "[STX] djkdsj [STX]dskd1[ETX] dsnds[ETX]" 
the output should be just "dskd1"

/*case 2*/ 
the above string can be "[STX] djkdsj [STX]dskd1[ETX] ddd" 
the output should be just "dskd1"

/*case 3*/ 
the above string can be " kdsj [STX]dskd1[ETX] dsnds[ETX]" 
the output should be just "dskd1"

/*case 4*/ 
the above string can be "[STX] djk[STX]dsj [STX]dskd2[ETX] ddd" 
the output should be just "dskd2"

The real problem comes when [STX] followed by [STX] i want to consider the newer [STX] and start string processing from the newer [STX] occurance. Eg. Case 2 above

=============================================================================

EDIT 3 : New Request

Language = C#

If i want the data between [STX] and [STX] also can that also be done.

New RegEx which will extract data between
1. [STX] some Data [STX]
2. [STX] some Data [ETX]

Eg.

/* the above string can be */
"[STX] djk[STX]dsj [STX]dskd2[ETX] ddd" 
/* the output should be just */
djk
dsj
dskd2

As [STX] means a transmission has been started so i want to extract data between STX as well.

  • 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-17T00:51:20+00:00Added an answer on May 17, 2026 at 12:51 am
    (?<=\[STX\])(?:(?!\[STX\]).)*?(?=\[ETX\])
    

    matches any text (except newlines) between [STX] and [ETX]:

    (?<=\[STX\])  # Are we right after [STX]? If so,...
    (?:           # match 0 or more of the following:
     (?!\[STX\])  # (as long as it's not possible to match [STX] here)
     .            # exactly one character
     )*?          # repeat as needed until...
    (?=\[ETX\])   # there is a [ETX] ahead.
    

    This will always match somestring in each of the following:

    blah blah [STX]somestring[ETX] blah blah
    [STX]somestring[ETX] blah [STX]somestring[ETX] (hey, two matches here!)
    [STX] not this! [STX]somestring[ETX] not this either! [ETX]
    blah [ETX] [STX]somestring[ETX] [STX] bla bla
    

    A full reference on positive/negative lookbehind and lookahead assertions (three of which are used in this regex) can be found in Jan Goyvaerts’ excellent regular expression tutorial at http://www.regular-expressions.info/lookaround.html.

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

Sidebar

Related Questions

Looking at the C# and VB.NET language specs I think it says that the
Maybe there are VB.net and other language that related with .Net framework. When I
I have a dll that contains a dot net assembly - common intermediate language.
What's the best way, using C# or other .NET language, to determine if a
I Adobe Air completly JavaScript? Can't I use a .NET language like VB.NET or
.NET Framework: 2.0 Preferred Language: C# I am new to TDD (Test Driven Development).
.NET, Java and other high level database API's in various language often provide techniques
What are the best conventions of naming testing-assemblies in .NET (or any other language
Similar to this question, but for VB.NET since I learned this is a language
I'm generating output for a .Net executable from my own language... the opcode (called

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.