@@ -49,17 +49,24 @@ private static void FillRowWithCapStrs(Object matchObject, out SqlString match,
4949 matchat = ( ( Match ) matchObject ) . Captures [ 0 ] . Index ;
5050 }
5151
52- public class PieceContext {
53- public int pieceOrderNo ; public string previousPiece ; public string piece ; public string nextPiece ;
52+ //-----------------------------------------------------------------------------------------------------------
53+ // Helper class for the PiecesWithContext only. The FillRowMethod only takes an object, so you can't send multiple
54+ // values to it. So we compile
55+ //-----------------------------------------------------------------------------------------------------------
56+ protected class PieceContext {
57+ public int pieceOrderNo ; public string previousPiece ; public string piece ; public string nextPiece ;
5458 public PieceContext ( int lpieceOrderNo , string lpreviousPiece , string lpiece , string lnextPiece )
5559 { pieceOrderNo = lpieceOrderNo ; previousPiece = lpreviousPiece ; piece = lpiece ; nextPiece = lnextPiece ; }
5660 }
5761
58- private static int returnpieceordernowithcontext = 0 ;
62+ /***************************************************************************************************************************************************************************************************
63+ *
64+ * Pull Out Matches by Regex and include the pieces before and after, making it easier to detect patterns.
65+ *
66+ **************************************************************************************************************************************************************************************/
5967 [ SqlFunction ( DataAccess = DataAccessKind . None , IsDeterministic = true , IsPrecise = true , FillRowMethodName = "FillRowWithStrPiecesWithContext" ) ]
6068 public static IEnumerable PiecesWithContext ( String stringtosplitintopieces , String regexmatchpattern )
6169 {
62- returnpieceordernowithcontext = 1 ;
6370 string [ ] stringpieces = Regex . Split ( stringtosplitintopieces , regexmatchpattern , RegexOptions . IgnoreCase , TimeSpan . FromSeconds ( 2 ) ) ;
6471
6572 var pieces = new List < PieceContext > ( stringpieces . Length ) ;
@@ -177,7 +184,7 @@ internal unsafe static string ReplaceRecursiveExt(this string input, string find
177184
178185 /***************************************************************************************************************************************************************************************************
179186 *
180- * Replace again and again. This is for when I want to remove all but one of spaces, or all the "******* " in a SQL proc header except one.
187+ * Replace again and again. This is for when I want to remove all but one of spaces, or all the " " in a SQL proc header except one.
181188 *
182189 **************************************************************************************************************************************************************************************/
183190 unsafe public static string ReplaceRecursive ( string input , string find , string replacement )
0 commit comments