public void FromPatternShouldMatchCorrectly17() { var re = new RegExp2("[----]"); Assert.True(re.Match("-")); Assert.False(re.Match(string.Empty)); }
public void FromPatternShouldMatchCorrectly() { var re = new RegExp2("a*b"); Assert.True(re.Match("aaaaaab")); Assert.True(re.Match("b")); Assert.False(re.Match("aa")); }
public void FromPatternShouldMatchCorrectly1() { var re = new RegExp2(string.Empty); Assert.True(re.Match(string.Empty)); Assert.False(re.Match("a")); Assert.False(re.Match(" ab")); }
public void FromPatternShouldMatchCorrectly11() { var re = new RegExp2(".+@.+\\.(com|net|org)"); Assert.True(re.Match("*****@*****.**")); Assert.True(re.Match("abab_dsdq&&[email protected]")); Assert.True(re.Match("++@()().net")); }
public void FromPatternShouldMatchCorrectly9() { var re = new RegExp2("(π|©)ю+_¡˚\\*"); Assert.True(re.Match("©ю_¡˚*")); Assert.True(re.Match("πюююююю_¡˚*")); Assert.False(re.Match("π_¡˚*")); }
public void FromPatternShouldMatchCorrectly21() { var re = new RegExp2("[\\^0-9]+"); Assert.True(re.Match("^")); Assert.True(re.Match("923481567")); Assert.False(re.Match(" ")); Assert.False(re.Match("AB()C")); }
public void FromPatternShouldMatchCorrectly6() { var re = new RegExp2("abc|def"); Assert.True(re.Match("abc")); Assert.True(re.Match("def")); Assert.False(re.Match("ab")); Assert.False(re.Match("ef")); }
public void FromPatternShouldMatchCorrectly12() { var re = new RegExp2("[1-9][0-9]*\\.[0-9]+"); Assert.True(re.Match("1.0")); Assert.True(re.Match("12300.0")); Assert.True(re.Match("99.999")); Assert.False(re.Match("01.1")); }
public void FromPatternShouldMatchCorrectly10() { var re = new RegExp2("a.*\\."); Assert.True(re.Match("aю_¡˚*.")); Assert.True(re.Match("abab_dsdqdwqd.")); Assert.True(re.Match("a.")); Assert.False(re.Match("baa.")); }
public void FromPatternShouldMatchCorrectly18() { var re = new RegExp2("[a-zA-]+"); Assert.True(re.Match("-")); Assert.True(re.Match("-aAa-")); Assert.True(re.Match("--")); Assert.False(re.Match(string.Empty)); }
public void FromPatternShouldMatchCorrectly22() { var re = new RegExp2("[a\\-z]"); Assert.True(re.Match("a")); Assert.True(re.Match("z")); Assert.True(re.Match("-")); Assert.False(re.Match("v")); Assert.False(re.Match("c")); }
public void FromPatternShouldMatchCorrectly15() { var re = new RegExp2("a{0,2},[a-z]{2,11},_{2,}"); Assert.True(re.Match("a,bz,__")); Assert.True(re.Match(",bzadwqve,____")); Assert.False(re.Match("aaa,bz,__")); Assert.False(re.Match("aaa,ppp,__")); Assert.False(re.Match("a,www,_")); }
public void FromPatternShouldMatchCorrectly13() { var re = new RegExp2("[a-z<;A-Z0-9,#\\-]+|_"); Assert.True(re.Match("1a<<<AccAER,ER-34#")); Assert.True(re.Match("a")); Assert.True(re.Match("B;;--;;;BBBBB99")); Assert.True(re.Match("_")); Assert.False(re.Match("_a")); }
public void FromPatternShouldMatchCorrectly23() { var re = new RegExp2("[01]*1[01]{5}"); var fsm = re.Automaton.Determinize(); //.Minimal(); Assert.True(fsm.Recognize("100000")); Assert.True(fsm.Recognize("111001")); Assert.True(fsm.Recognize("010101111001")); Assert.True(fsm.Recognize("000101110")); Assert.False(fsm.Recognize("000000")); }
public void FromPatternShouldMatchCorrectly20() { var re = new RegExp2("[^0-9?\\-^a-z]+"); Assert.True(re.Match(" ")); Assert.True(re.Match("AB()C")); Assert.False(re.Match("-")); Assert.False(re.Match("923481567")); Assert.False(re.Match("vstgko")); Assert.False(re.Match("?")); Assert.False(re.Match("^")); }
public void FromPatternShouldMatchCorrectly8() { var re = new RegExp2("(ab|e)+c?dd"); Assert.True(re.Match("abeeabdd")); Assert.True(re.Match("eecdd")); Assert.True(re.Match("eabdd")); Assert.True(re.Match("ecdd")); Assert.False(re.Match("eabddd")); Assert.False(re.Match("eccdd")); Assert.False(re.Match(string.Empty)); }
public void FromPatternShouldMatchCorrectly7() { var re = new RegExp2("a(b*|c)"); Assert.True(re.Match("ac")); Assert.True(re.Match("abbbb")); Assert.True(re.Match("ab")); Assert.True(re.Match("a")); Assert.False(re.Match("abc")); Assert.False(re.Match("acc")); Assert.False(re.Match(string.Empty)); }
public void FromPatternShouldMatchCorrectly4() { var re = new RegExp2("(0|(1(01*(00)*0)*1)*)*"); Assert.True(re.Match(string.Empty)); Assert.True(re.Match("0")); Assert.True(re.Match("00")); Assert.True(re.Match("11")); Assert.True(re.Match("000")); Assert.True(re.Match("011")); Assert.True(re.Match("110")); Assert.True(re.Match("0000")); Assert.True(re.Match("0011")); }
public void FromPatternShouldMatchCorrectly19() { var re = new RegExp2("[^abc]"); Assert.True(re.Match("d")); Assert.True(re.Match("e")); Assert.False(re.Match("a")); Assert.False(re.Match("b")); Assert.False(re.Match("c")); var re1 = new RegExp2("[^\"\\\\]"); Assert.True(re1.Match("a")); Assert.True(re1.Match("e")); Assert.False(re1.Match("\\\\")); Assert.False(re1.Match("\"")); }
public void FromPatternShouldMatchCorrectly5() { var re = new RegExp2("(a|b)*c"); Assert.True(re.Match("c")); Assert.True(re.Match("ac")); Assert.True(re.Match("ababc")); Assert.True(re.Match("bbbc")); Assert.True(re.Match("aaaaaaac")); Assert.True(re.Match("ac")); Assert.True(re.Match("bac")); Assert.True(re.Match("abbbbc")); Assert.False(re.Match("cc")); Assert.False(re.Match("a")); Assert.False(re.Match("b")); Assert.False(re.Match("ababab")); }
public void FromPatternShouldMatchCorrectly16() { var re = new RegExp2("a{2,}"); Assert.True(re.Match("aa")); Assert.True(re.Match("aaa")); Assert.True(re.Match("aaaaaa")); Assert.False(re.Match("a")); var re1 = new RegExp2("a{2}"); Assert.True(re1.Match("aa")); Assert.False(re1.Match("a")); Assert.False(re1.Match("aaa")); Assert.False(re1.Match("aaaa")); var re2 = new RegExp2("a{2,4}"); Assert.True(re2.Match("aa")); Assert.True(re2.Match("aaa")); Assert.True(re2.Match("aaaa")); Assert.False(re2.Match("a")); Assert.False(re2.Match("aaaaa")); }
static void Main(string[] args) { ParseArgs(args); //RegExp1 = new Regex(@"(?:<H3>\ *?(\w\w\w)(.*?)<\/H3>"); var FilesToParse = Directory.GetFiles(DirToParse).ToList(); var captureBlock = 1; int captureIndex; using (conn) { var q = new SqlCommand("Select isnull(Max(CaptureIndex),0) from RegexCaptureTable", conn); conn.Open(); using (SqlDataReader _reader = q.ExecuteReader()) { if (_reader.HasRows) { _reader.Read(); captureIndex = Convert.ToInt32(_reader[0]) + 1; } else { captureIndex = 1; } } //iteramos los ficheros FilesToParse.ForEach(f => { //obtenemos el contenido //var path = string.Format("{0}\\{1}", DirToParse, f); var fileContent = File.ReadAllText(f); //var reg = new Regex(@"<H3> *(\w\w\w) *(.*?)<\/H3>\r\n\r\n Function:(.*?)\r"); var match1 = RegExp1.Matches(fileContent); var match2 = RegExp2.Matches(fileContent); //Regex.Matches(fileContent, @"<H3>\ *?(?<code>\w\w\w)(?<description>.*?)<\/H3>\r\n"); //var match2 = Regex.Matches(fileContent, RegExp2); foreach (Match match in match1) { bool skip = true; foreach (Group group in match.Groups) { if (!skip) { using (SqlCommand insertQuery = new SqlCommand(string.Format("INSERT INTO [RegexCaptureTable] ([CaptureIndex],[CaptureBlock],[DependingBlock],[Field]) VALUES ({0},{1},null,'{2}')", captureIndex, captureBlock, group.ToString()), conn)) { try { insertQuery.ExecuteNonQuery(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } skip = false; } } var dependingCapture = captureBlock; captureBlock++; foreach (Match match in match2) { bool skip = true; foreach (Group group in match.Groups) { if (!skip) { using (SqlCommand insertQuery = new SqlCommand(string.Format("INSERT INTO [RegexCaptureTable] ([CaptureIndex],[CaptureBlock],[DependingBlock],[Field]) VALUES ({0},{1},{2},'{3}')", captureIndex, captureBlock, dependingCapture, group), conn)) { try { insertQuery.ExecuteNonQuery(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } skip = false; } captureBlock++; } }); } }