Click here to Skip to main content
15,902,745 members
Home / Discussions / C#
   

C#

 
GeneralRe: ListBox won't bind Pin
Mustafa Ismail Mustafa5-Aug-09 5:19
Mustafa Ismail Mustafa5-Aug-09 5:19 
GeneralRe: ListBox won't bind Pin
Henry Minute5-Aug-09 5:35
Henry Minute5-Aug-09 5:35 
GeneralRe: ListBox won't bind Pin
Mustafa Ismail Mustafa5-Aug-09 5:38
Mustafa Ismail Mustafa5-Aug-09 5:38 
GeneralRe: ListBox won't bind Pin
Henry Minute5-Aug-09 5:41
Henry Minute5-Aug-09 5:41 
GeneralRe: ListBox won't bind Pin
Mustafa Ismail Mustafa5-Aug-09 5:47
Mustafa Ismail Mustafa5-Aug-09 5:47 
GeneralRe: ListBox won't bind Pin
Mustafa Ismail Mustafa5-Aug-09 5:35
Mustafa Ismail Mustafa5-Aug-09 5:35 
GeneralRe: ListBox won't bind Pin
Henry Minute5-Aug-09 5:38
Henry Minute5-Aug-09 5:38 
QuestionHelp in matching inputted string to a regex pattern Pin
gamer11275-Aug-09 2:05
gamer11275-Aug-09 2:05 
Can someone help me on how to match an entered string to a regex pattern?

I'm creating a program that would parse a for loop statement and check if the entered for loop statement is correct or not. So far I've been able to split that statement and pass it into an array. I then pass it again to a string variable after i put the splitted statement into that array. My only problem is how to check if the entered for loop statement is correct? I've been trying lots of pattern matching codes from the web but none of them have worked so far. The deadline will be next week but until now there hasn't been any progress.

My pattern isn't done yet too because i can't make a pattern that would match the >=, <= relational operators and the '--', '++' unary operators.

To make things easier, this is my code:

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

namespace MachineProblem
{
    class Program
    {

        static void Main(string[] args)
        {
        
            string passedStatement = " ";
            string[] stringHolder = null;

            GetStatement(stringHolder, ref passedStatement);
            SyntaxVerifier(stringHolder, ref passedStatement);

            Console.Read();

        }

        public static void GetStatement(string[] arrayBox, ref string statement)
        {

            Console.WriteLine("Write an example of a for loop statement: ");
            statement = Console.ReadLine();

            foreach (string token in Tokenizer(arrayBox, statement))
            {
                
            }

        }

        //the function that tokenizes the string
        public static string[] Tokenizer(string[] strBox, string tokenizeStatement)
        {

            strBox = null;

            //marks the end of the string to be tokenized
            Regex strTokenizer = new Regex(@"([\;\(\)\ \\])");

            for (int i = 0; i < strTokenizer.Split(tokenizeStatement).Length; i++)
            {

                //tokenized string passed to an empty array
                strBox = strTokenizer.Split(tokenizeStatement);

            }

            return strBox;

        }

        //the function used to check the entered statement if it's a correct syor not
        public static void SyntaxVerifier(string[] arrayString, ref string passedsyntax)
        {
            string pattern = @"(for\s*[\(]\s*int\s*[a-zA-Z\d]*\s*=\s*[\d]*\s*;\s*[a-zA-Z\d]*\s*[\<\>]\s*[\d]\s*;\s*[a-zA-z\d]*\s*[\-(1)])";
            string stringStatement = "for(int x=0; x<5; x++) Console.WriteLine(\"Hello\")";

            //arrayString = null;

            //arrayString = Tokenizer(arrayString, passedsyntax);


            foreach (string words in arrayString)
            {
                stringStatement = words;
                stringStatement.Trim();

            }
        }

    }
}



Thanks in Advance for those who could help Big Grin | :-D
AnswerRe: Help in matching inputted string to a regex pattern Pin
musefan5-Aug-09 2:22
musefan5-Aug-09 2:22 
AnswerRe: Help in matching inputted string to a regex pattern Pin
gamer11275-Aug-09 2:31
gamer11275-Aug-09 2:31 
GeneralRe: Help in matching inputted string to a regex pattern Pin
OriginalGriff5-Aug-09 2:54
mveOriginalGriff5-Aug-09 2:54 
GeneralRe: Help in matching inputted string to a regex pattern Pin
molesworth5-Aug-09 3:07
molesworth5-Aug-09 3:07 
GeneralRe: Help in matching inputted string to a regex pattern Pin
gamer11275-Aug-09 4:00
gamer11275-Aug-09 4:00 
GeneralRe: Help in matching inputted string to a regex pattern Pin
riced5-Aug-09 4:22
riced5-Aug-09 4:22 
GeneralRe: Help in matching inputted string to a regex pattern Pin
gamer11275-Aug-09 4:39
gamer11275-Aug-09 4:39 
GeneralRe: Help in matching inputted string to a regex pattern Pin
riced5-Aug-09 4:44
riced5-Aug-09 4:44 
QuestionSerializationBinder and parsing type fullname Pin
Super Lloyd5-Aug-09 1:46
Super Lloyd5-Aug-09 1:46 
AnswerRe: SerializationBinder and parsing type fullname Pin
Super Lloyd5-Aug-09 4:00
Super Lloyd5-Aug-09 4:00 
GeneralRe: SerializationBinder and parsing type fullname Pin
Super Lloyd5-Aug-09 5:27
Super Lloyd5-Aug-09 5:27 
QuestionHow to test Web Methods with NUnit Pin
Phillip Donegan5-Aug-09 1:26
Phillip Donegan5-Aug-09 1:26 
Questionbyte array To text box is it possible? Pin
gwithey5-Aug-09 1:24
gwithey5-Aug-09 1:24 
AnswerRe: byte array To text box is it possible? Pin
musefan5-Aug-09 2:16
musefan5-Aug-09 2:16 
QuestionConvert String To Unix Timestamp Pin
iNutR5-Aug-09 0:27
iNutR5-Aug-09 0:27 
AnswerRe: Convert String To Unix Timestamp Pin
Christian Graus5-Aug-09 0:31
protectorChristian Graus5-Aug-09 0:31 
GeneralRe: Convert String To Unix Timestamp Pin
iNutR5-Aug-09 0:36
iNutR5-Aug-09 0:36 

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.