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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:46:57+00:00 2026-06-17T20:46:57+00:00

There are segments in the below-mentioned string. Each segment is started with a tilt(~)

  • 0

There are segments in the below-mentioned string. Each segment is started with a tilt(~) sign and I want to check if there exists a segment in which the AAA segment appears and on its 3rd index a number 63 is present.

ISA*ABC**TODAY*ALEXANDER GONZALEZ~HL*CDD*DKKD*S~EB*1*AKDK**DDJKJ~AAA*Y**50*P~AAA*N**50*P~AAA*N**63*C~AAA*N**50*D~AAA*N**45*D

I want to do it with a regular expression to avoid lengthy coding. I have tried and come up with this (~AAA) to check if this segment exists or not but because I am new to regular expressions I don’t know how to check if 63 appears on the 3rd index or not? If anyone can help I will be very thankful.

  • 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-17T20:46:58+00:00Added an answer on June 17, 2026 at 8:46 pm

    I have to agree with Sebastian’s comment. This can be accomplished using simple Split operations.

        private static bool Check(string input)
        {
            int count = 0;
            foreach (string segment in input.Split('~'))
            {
                string[] tokens = segment.Split('*');
                if (tokens[0] == "AAA")
                {
                    count++;
                    if (count == 3)
                    {
                        if (tokens[3] == "63") return true;
                        else return false;
                    }
                }
            }
            return false;
        }
    

    EDIT:
    Since you want fewer lines of codes, how about LINQ?

        private bool Check(string input)
        {
            return input.Split('~').Select(x => x.Split('*')).Any(x => x.Length >= 4 && x[0].Equals("AAA") && x[3].Equals("63"));
        }
    

    EDIT2:
    For completeness, here’s a Regex solution as well:

        private bool Check(string input)
        {
            return Regex.IsMatch(input, @".*~AAA\*([^\*~]*\*){2}63.*");
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a python program which splits up a files into segments
There is an example on php.net how to get last two domain segments in
Does Windows have the notion of system-wide shared memory segments and is there a
The code segment is from a page called sites-catchup.html. There is a simple server
I have two array and three button in segment control i want that when
There is a column that exists in 2 tables. In table 1, this column
There's a Rails 3.2.3 web application which doesn't use any database. But in spite
There is a directed graph having a single designated node called root from which
There are two intents on the receiver side which are called from the same
So I know there are a lot of questions about printing only segments of

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.