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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:42:14+00:00 2026-05-30T21:42:14+00:00

Hello Everybody i asked this question few hours ago C# get username from string.

  • 0

Hello Everybody i asked this question few hours ago C# get username from string. split

Now i have difficult problem. Trying to get Acid Player And m249 from this string

    L 02/28/2012 - 06:14:22: "Acid<1><VALVE_ID_PENDING><CT>" 
killed "Player<2><VALVE_ID_PENDING><TERRORIST>" with "m249"

I tried this

int start = Data.ToString().IndexOf('"') + 1;
            int end = Data.ToString().IndexOf('<');
            var Killer = Data.ToString().Substring(start, end - start);

            int start1 = Data.ToString().IndexOf("killed") + 1;
            int end1 = Data.ToString().IndexOf('<') + 4;
            var Victim = Data.ToString().Substring(start1, end1 - start1);

but its show this exception on last line

Length cannot be less than zero.
Parameter name: length

Does it possible to get Both player name and last string (m249)

Tanks

  • 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-30T21:42:16+00:00Added an answer on May 30, 2026 at 9:42 pm

    Here is a simple example of how you can do it with regex. Depending on how much the string varies, this one may work for you. I’m assuming that quotes (“) are consistent as well as the text between them. You’ll need to add this line at the top:

    Using System.Text.RegularExpressions;

    Code:

    string input = "L 02/28/2012 - 06:14:22: \"Acid<1><VALVE_ID_PENDING><CT>\" killed \"Player<2><VALVE_ID_PENDING><TERRORIST>\" with \"m249\"";
    Regex reg = new Regex("[^\"]+\"([^<]+)<[^\"]+\" killed \"([A-Za-z0-9]+)[^\"]+\" with \"([A-Za-z0-9]+)\"");
    Match m = reg.Match(input);
    if (m.Success)
    {
        string player1 = m.Groups[1].ToString();
        string player2 = m.Groups[2].ToString();
        string weapon = m.Groups[3].ToString();
    }
    

    The syntax breakdown for the regex is this:

    [^\”]+

    means, go till we hit a double quote (“)

    \”

    means take the quote as the next part of the string, since the previous term brings us to it, but doesn’t go past it.

    ([^<]+)<

    The parenthesis means we are interested in the results of this part, we will seek till we hit a less than (<). since this is the first “group” we’re looking to extract, it’s referred to as Groups[1] in the match. Again we have the character we were searching for to consume it and continue our search.

    <[^\”]+\” killed \”

    This will again search, without keeping the results due to no parenthesis, till we hit the next quote mark. We then manually specify the string of (” killed “) since we’re interested in what’s after that.

    ([A-Za-z0-9]+)

    This will capture any characters for our Group[2] result that are alphanumeric, upper or lowercase.

    [^\”]+\”

    Search and ignore the rest till we hit the next double quote

    with \”

    Another literal string that we’re using as a marker

    ([A-Za-z0-9]+)

    Same as above, return alphanumeric as our Group[3] with the parenthesis

    \”

    End it off with the last quote.

    Hopefully this explains it. A google for “Regular Expressions Cheat Sheet” is very useful for remembering these rules.

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

Sidebar

Related Questions

Hello everybody I have this string: [JOLLY BLU at STAY SHIP, Voy: 0275/11] How
Hello everybody I have a question: I have a array String[] parte and I
Suppose I have String str=Hello $everybody$. How $are$ you $all$; From above string, I
Hello everybody I've recently asked this question and I've given up with the 'replace
Note: This question is posted here hello everybody, I have a predefind list of
Hello everybody I have a LINQ declaration like this : var query = from
My string contain a lot of HTML entities, like this &#x22;Hello&nbsp;&lt;everybody&gt;&nbsp;there&#x22; And I want
Hello everybody Well my question is about sql commands... If I have 2 tables
Hello everybody and sorry for the rather confusing question-title. I have a Hibernate Class
hello everybody i have been asked to design a general login page (and others)

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.