Click here to Skip to main content
15,911,503 members
Home / Discussions / C#
   

C#

 
AnswerRe: one to many class association Pin
Nader Elshehabi24-Aug-06 10:51
Nader Elshehabi24-Aug-06 10:51 
Questionusing Sission by c# Pin
mhattiyah24-Aug-06 4:46
mhattiyah24-Aug-06 4:46 
AnswerRe: using Sission by c# Pin
ToddHileHoffer24-Aug-06 5:10
ToddHileHoffer24-Aug-06 5:10 
Questioninconsistency in virtual dir Pin
Kunal P24-Aug-06 4:31
Kunal P24-Aug-06 4:31 
AnswerRe: inconsistency in virtual dir Pin
Ennis Ray Lynch, Jr.24-Aug-06 9:15
Ennis Ray Lynch, Jr.24-Aug-06 9:15 
GeneralRe: inconsistency in virtual dir Pin
Kunal P24-Aug-06 20:03
Kunal P24-Aug-06 20:03 
GeneralRe: inconsistency in virtual dir Pin
Guffa24-Aug-06 22:42
Guffa24-Aug-06 22:42 
QuestionDoh! Regular Expressions and C# Strings [modified] Pin
Brent Lamborn24-Aug-06 4:24
Brent Lamborn24-Aug-06 4:24 
Sorry to post this but, here goes.

All of the coding I've ever done, and gotten paid for it, has been VB. I'm working on a project now that I decide to do in C#. It's a breath of fresh air, let me tell ya. It reminds of my days in college doing C++ and makes me realize how brain dead doing VB can make a guy!

Anyway, what's with this escape character stuff in C# strings? I'm having a heck of a time coming up with a regular expression that will match IP addresses with leading zeros, and I think my problem may be the escape character "/". I tried replacing / with // but still no matches. In fact every regex I found on the web for IP addresses failed to match.

Here is the function:

private void RangeCheck()
       {
           String sLine = "";
           String  sIPMatcher = "(\\[0-9]{1,3})\\.(\\[0-9]{1,3})\\.(\\[0-9]{1,3})\\.(\\[0-9]{1,3})";

           RegexStringValidator test = new RegexStringValidator(sIPMatcher);
           StreamReader sr = new StreamReader("c:/UniqueIPaddr_list.csv");

           while (!sr.EndOfStream)
           {
               sLine = sr.ReadLine();

               try
               {
                   test.Validate(sLine);
                   if (IPList.CheckNumber(sLine))
                   {
                       lstBox.Items.Add(sLine);
                   }
               }
               catch
               {
               }
           }
       }


IPList is a class I borrowed from Bo's article here[^].

And here is an example of one of 10,000+ IP address in the .csv file: 00x.0xx.xxx.0x0
where x is any number 1-9 (didn't want to disclose an acutal IP).


No matter what I try, no matches occur. D'Oh! | :doh: Is it my lack of C# skills, or just use of an incorrect regex?






-- modified at 10:25 Thursday 24th August, 2006

"Half this game is ninety percent mental." - Yogi Berra

If you can read thank a teacher, if you can read in English, thank a Marine.

M y and h don't work so well due to m addiction to caffeine and m in abilit to to set a cup down uprigt.


AnswerRe: Doh! Regular Expressions and C# Strings Pin
Coding C#24-Aug-06 4:38
Coding C#24-Aug-06 4:38 
GeneralRe: Doh! Regular Expressions and C# Strings Pin
User 665824-Aug-06 5:31
User 665824-Aug-06 5:31 
AnswerRe: Doh! Regular Expressions and C# Strings Pin
coolestCoder24-Aug-06 4:42
coolestCoder24-Aug-06 4:42 
GeneralRe: Doh! Regular Expressions and C# Strings Pin
Brent Lamborn24-Aug-06 6:26
Brent Lamborn24-Aug-06 6:26 
GeneralRe: Doh! Regular Expressions and C# Strings [modified] Pin
coolestCoder24-Aug-06 19:52
coolestCoder24-Aug-06 19:52 
GeneralRe: Doh! Regular Expressions and C# Strings Pin
Coding C#24-Aug-06 20:19
Coding C#24-Aug-06 20:19 
GeneralRe: Doh! Regular Expressions and C# Strings Pin
Brent Lamborn25-Aug-06 4:17
Brent Lamborn25-Aug-06 4:17 
Questionrefreshing the printer folder Pin
AnnnS24-Aug-06 4:23
AnnnS24-Aug-06 4:23 
QuestionRecording Control [modified] Pin
Mohammad Hajjat24-Aug-06 4:08
Mohammad Hajjat24-Aug-06 4:08 
AnswerRe: Recording Control Pin
Nader Elshehabi24-Aug-06 11:05
Nader Elshehabi24-Aug-06 11:05 
GeneralRe: Recording Control Pin
Mohammad Hajjat26-Aug-06 20:36
Mohammad Hajjat26-Aug-06 20:36 
AnswerRe: Recording Control Pin
Nader Elshehabi26-Aug-06 21:27
Nader Elshehabi26-Aug-06 21:27 
GeneralRe: Recording Control Pin
Mohammad Hajjat26-Aug-06 21:37
Mohammad Hajjat26-Aug-06 21:37 
QuestionNetworking in C# Pin
coolestCoder24-Aug-06 4:06
coolestCoder24-Aug-06 4:06 
AnswerRe: Networking in C# Pin
Nader Elshehabi24-Aug-06 10:25
Nader Elshehabi24-Aug-06 10:25 
QuestionBest option for IE hosted user control vs. stand-alone Pin
BambooMoon24-Aug-06 4:04
BambooMoon24-Aug-06 4:04 
QuestionHow to open file use default application in C# Pin
txwd24-Aug-06 3:37
txwd24-Aug-06 3:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.