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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:12:32+00:00 2026-06-04T14:12:32+00:00

I am trying to write a program that scans the surround WiFi networks and

  • 0

I am trying to write a program that scans the surround WiFi networks and dumps the info into an array containing the SSID and Encryption type. The SSID dynamic array would then be compared with a static array trying to match SSIDs together then outputing results.

I am having trouble trying create the dynamic array putting just the SSID and Encryption in using Regex. The output of the Network dump looks like this:

Interface name : Wireless Network Connection 
There are 8 networks currently visible. 

SSID 1 : TheChinaClub-5G
    Network type            : Infrastructure
    Authentication          : WPA2-Personal
    Encryption              : CCMP 

I’ve tried to use SSID as the key with the following number as a wildcard (but don’t know the syntax) and grab the data after the colon excluding the space. As of right now nothing works except for the network dump. The regex doesn’t seem to be finding anything. I’ve been using this post for the model of the regex.

Here is the code I have thus far:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;

namespace Rainbownetworks
{
    public struct Networkarr
    {
        public string x, y;

        public Networkarr(string SSID, string Encryption)
        {
            x = SSID;
            y = Encryption;
        }
    }

     class Program
    {

        static void Main(string[] args)
        {
            string[] StaticSSIDarr = { "network1", "network2", "network3" };
            string[] Networkarr = { };


            Process p = new Process();
            p.StartInfo.FileName = "netsh.exe";
            p.StartInfo.Arguments = "wlan show networks";
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.RedirectStandardOutput = true;
            p.Start();
            string results = p.StandardOutput.ReadToEnd();

            string[] SSIDs = { "SSID *"};

            FindSSIDs(SSIDs, results);

            Console.WriteLine(results);
            Console.ReadLine();




        }

        private static void FindSSIDs(IEnumerable<string> keywords, string source)
        {
            var found = new Dictionary<string, string>(10);
            var keys = string.Join("|", keywords.ToArray());
            var matches = Regex.Matches(source, @"(?<key>" + keys + "):",
                                  RegexOptions.IgnoreCase);

            foreach (Match m in matches)
            {
                var key = m.Groups["key"].ToString();
                var start = m.Index + m.Length;
                var nx = m.NextMatch();
                var end = (nx.Success ? nx.Index : source.Length);
                found.Add(key, source.Substring(start, end - start));
            }

            foreach (var n in found)
            {
                Networkarr newnetwork = new Networkarr(n.Key, n.Value);
                Console.WriteLine("Key={0}, Value={1}", n.Key, n.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-06-04T14:12:33+00:00Added an answer on June 4, 2026 at 2:12 pm

    Try this

    try {
        Regex regexObj = new Regex(@"(?<=SSID\s*\d+ :\s*)(?<value>\S+)");
        Match matchResults = regexObj.Match(subjectString);
        while (matchResults.Success) {
            for (int i = 1; i < matchResults.Groups.Count; i++) {
                Group groupObj = matchResults.Groups[i];
                if (groupObj.Success) {
                    // matched text: groupObj.Value
                    // match start: groupObj.Index
                    // match length: groupObj.Length
                } 
            }
            matchResults = matchResults.NextMatch();
        } 
    } catch (ArgumentException ex) {
        // Syntax error in the regular expression
    }
    

    Explanation

    @"
    (?<=         # Assert that the regex below can be matched, with the match ending at this position (positive lookbehind)
       SSID         # Match the characters “SSID” literally
       \s           # Match a single character that is a “whitespace character” (spaces, tabs, and line breaks)
          *            # Between zero and unlimited times, as many times as possible, giving back as needed (greedy)
       \d           # Match a single digit 0..9
          +            # Between one and unlimited times, as many times as possible, giving back as needed (greedy)
       \ :          # Match the characters “ :” literally
       \s           # Match a single character that is a “whitespace character” (spaces, tabs, and line breaks)
          *            # Between zero and unlimited times, as many times as possible, giving back as needed (greedy)
    )
    (?<value>    # Match the regular expression below and capture its match into backreference with name “value”
       \S           # Match a single character that is a “non-whitespace character”
          +            # Between one and unlimited times, as many times as possible, giving back as needed (greedy)
    )
    "
    

    Hope this helps.

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

Sidebar

Related Questions

I'm trying to write a program that scans in values from the console and
I'm trying to write a program that converts a long into a string and
I am trying to write a program that will hook into application startup and
I'm trying to write a program that reads in entries from a file into
I am trying to write a program that allows a binary to be run,
I am trying to write a program that displays the integers between 1 and
i am trying to write a program that close explorer then runs another program.
I am trying to write a program that has a vector of char arrays
I'm trying to write a program that can stop and start services using SilverLight
I'm trying to write a program that takes a large file (of any type)

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.