using System; //abc static void Match_ABC(ReadOnlySpan input) { int ptr = 0; int region_start = ptr; int region_end = region_start; const string pattern = @"abc"; if(input[0..3].SequenceEqual(pattern)) { ptr += 3; region_end = ptr; } } //a[abc]d static void Match_A_charset_ABC_C(ReadOnlySpan input) { int ptr = 0; int region_start = ptr; int region_end = region_start; if(input[0] == 'a' && (input[1] == 'a' || input[1] == 'b' || input[1] == 'c') && input[2] == 'd') { ptr += 3; region_end = ptr; } } //[abc] static void Match_charset_ABC(ReadOnlySpan input) { int ptr = 0; int region_start = ptr; int region_end = region_start; if(input[0] == 'a' || input[0] == 'b' || input[0] == 'c') { ptr += 1; region_end = ptr; } } //. static void Match_Dot(ReadOnlySpan input) { int ptr = 0; int region_start = ptr; int region_end = region_start; ptr += 1; region_end = ptr; } //a{3,5} static void Match_A_3_5(ReadOnlySpan input) { int ptr = 0; int region_start = ptr; int region_end = region_start; do { if(input[ptr..].StartsWith("aaa")) { ptr += 3; region_end = ptr; } else { break; } for(int i = 0; i < 2; i++) { if(input[ptr] == 'a') { ptr += 1; region_end = ptr; } else { break; } } } while(false); } //(ab){2,3} static void Match_AB_2_3(ReadOnlySpan input) { int ptr = 0; int region_start = ptr; int region_end = region_start; do { if(input[ptr..].StartsWith("abab")) { ptr += 4; region_end = ptr; } else { break; } for(int i = 0; i < 1; i++) { if(input[ptr..].StartsWith("ab")) { ptr += 2; region_end = ptr; } else { break; } } } while(false); } // (ab|[cd]|.)x static void MatchDiffCase(ReadOnlySpan seq) { /* * [000] 0001, DEF , Sccs, NONE, 0000, MATCH_SEQ "ab" * [001] 0001, Fail, Sccs, LINE, 0000, MATCH_SET "[cd]" * [002] 0001, Fail, Sccs, LINE, 0001, MATCH_SET "." * [003] 0000, Fail, DEF , LINE, 0002, POP FAIL * [004] 0000, DEF , DEF , NONE, 0000, MATCH_SEQ "x" */ int ptr = 0; if(seq.StartsWith("ab")) { ptr+=2; } else if((seq[0] == 'c' || seq[0] == 'd')) { ptr+=1; } else if(true) { ptr+=1; } else { return; } } // (?.*)x static void MatchCountAnyGroup(ReadOnlySpan seq) { /* * [000] 0001, DEF , DEF , NONE, 0000, FIND_COMPLEX FURTHEST COUNT: -1 * [001] 0001, Sccs, DEF , LINE, 0000, PACK SUCCESS GROUP: "name" * [002] 0000, DEF , DEF , NONE, 0000, MATCH_SEQ "234" */ int ptr = 0; int group_start = ptr; int furthest = -1; do { if((furthest = seq.LastIndexOf("123"))>0) { ptr += furthest + 3; break; } } while(true); // grouping if(furthest >= 0) { ptr = furthest; int group_end = ptr; // group "name" matched from group_start to group_end } }