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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:57:48+00:00 2026-05-12T16:57:48+00:00

im trying to learn about regex, and how to use it braking up som

  • 0

im trying to learn about regex, and how to use it braking up som logs and populating som textboxes with the results.

if i have a simple line like this

Port status: tro-S-02-av1 0/23

and want to put the tro-S-02-av1 and the 0/23 in a variable

all names wold end on av1 so the regular exspression shold be based on this.

i was thinking like this to try to get the string of tro-S-02-av1 to become the value a text box but i cant get it right, how can i do this.

    Regex r;
    Match m;

    r = new Regex("$`\av1");
    m = r.Match("Port status: tro-S-02-av1 0/23");

    nodetbx.Text = m.Value;
  • 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-12T16:57:49+00:00Added an answer on May 12, 2026 at 4:57 pm

    Using groups with the following regex (for example, you could probably clean this up)

    Port status: (?<ID>[\d\w\-]+)\s(?<ID2>[\s\S]+)
    

    Will give you two named groups, ID1 and ID2 you can then populate.

    I found using named groups easier when first learning regex so you can really see what’s going on.

    Take a look at nregex to help practice and test regexs too.

        regex r = new regex("Port status: (?<ID>[\d\w\-]+)\s(?<ID2>[\s\S]+)");
        matchcollection mc = r.matches(MyText);
        foreach (match m in mc) {
            string ID1 = m.groups("ID1");
            string ID2 = m.groups("ID2");
        }
    

    Where MyText is either each line looping through the file with ReadLine or the whole file if not too big.

    You can then use ID1 and ID2 (renamed to something meaningful) to populate textbox or whatever.

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

Sidebar

Related Questions

Trying to learn about php's arrays today. I have a set of arrays like
I'm trying to learn about condition variables and how to use it in a
I am trying to learn about Google maps API. I have a project that
I'm trying to learn about shift-reduce parsing. Suppose we have the following grammar, using
I'm trying to learn about stack base overflow and write a simple code to
I have been trying to learn about classes in PHP and part of my
I have trying to learn about resources. In VS when I create the project:
I have been trying to learn about dependency injection and have been reading about
I'm trying to learn about loops and I currently have a long list of
I'm trying to learn about using Doctrine 2 by making a very simple script

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.