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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:27:06+00:00 2026-05-12T18:27:06+00:00

Here is the data source, lines stored in a txt file: servers[i]=[name1, type1, location3];

  • 0

Here is the data source, lines stored in a txt file:

servers[i]=["name1", type1, location3];
servers[i]=["name2", type2, location3];
servers[i]=["name3", type1, location7];

Here is my code:

    string servers = File.ReadAllText("servers.txt");
    string pattern = "^servers[i]=[\"(?<name>.*)\", (.*), (?<location>.*)];$";

    Regex reg = new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.Multiline);
    Match m;

    for (m = reg.Match(servers); m.Success; m = m.NextMatch()) {
        string name = m.Groups["name"].Value;
        string location = m.Groups["location"].Value;                
    }

No lines are matching. What am I doing wrong?

  • 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-12T18:27:06+00:00Added an answer on May 12, 2026 at 6:27 pm

    I don’t know if C# regex’s are the same as perl, but if so, you probably want to escape the [ and ] characters. Also, there are extra characters in there. Try this:

    string pattern = "^servers\[i\]=\[\"(?<name>.*)\", (.*), (?<location>.*)\];$";
    

    Edited to add: After wondering why my answer was downvoted and then looking at Val’s answer, I realized that the “extra characters” were there for a reason. They are what perl calls “named capture buffers”, which I have never used but the original code fragment does. I have updated my answer to include them.

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

Sidebar

Related Questions

Data: Here is sample table(TableA) data ID StartTime EndTime 1 2012-03-22 06:00:00.000 2012-03-22 06:30:00.000
I am sending HTTP GET request and receiving data here: ssize_t numBytes = recvfrom(sock,
I'm learning assembly and I have a very basic loop here segment .data msg:
for (i = 0; i < 14; i++) { //display data here } Console.WriteLine({0},
My html is like this <div id=rsContainer> <table id=rsTable><!-- DATA HERE --></table> </div> and
Here is my data returned from a CMS function: array ( 0 => stdClass::__set_state(array(
here is my data: +----+------------------+--------------------+ | ID | DateTime Entered | DateTime Completed |
Here is my data structure alt text http://luvboy.co.cc/images/db.JPG when i try this sql select
Here is sample data <table class=sparql border=1> <tr> <th>abstract</th></tr> <tr> <td> Cologne is Germany&#39;s
I'm doing some data analytics aggregations and here is my data structures: { 12300

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.