public string Dump(string indent) { StringBuilder sb = new StringBuilder(); sb.Append(indent + "BM Pattern: " + Pattern + "\n"); sb.Append(indent + "Positive: "); for (int i = 0; i < Positive.Length; i++) { sb.Append(Positive[i].ToString(CultureInfo.InvariantCulture) + " "); } sb.Append("\n"); if (NegativeASCII != null) { sb.Append(indent + "Negative table\n"); for (int i = 0; i < NegativeASCII.Length; i++) { if (NegativeASCII[i] != Pattern.Length) { sb.Append(indent + " " + RegexParser.Escape(Convert.ToString((char)i, CultureInfo.InvariantCulture)) + " " + NegativeASCII[i].ToString(CultureInfo.InvariantCulture) + "\n"); } } } return(sb.ToString()); }
/// <summary> /// Escapes a minimal set of metacharacters (\, *, +, ?, |, {, [, (, ), ^, $, ., #, and /// whitespace) by replacing them with their \ codes. This converts a string so that /// it can be used as a constant within a regular expression safely. (Note that the /// reason # and whitespace must be escaped is so the string can be used safely /// within an expression parsed with x mode. If future Regex features add /// additional metacharacters, developers should depend on Escape to escape those /// characters as well.) /// </summary> public static string Escape(string str) { if (str == null) throw new ArgumentNullException(nameof(str)); return RegexParser.Escape(str); }
public static string Escape(string str) { if (str == null) { throw new ArgumentNullException(); } return(RegexParser.Escape(str)); }
public void Dump() { int i; Debug.WriteLine("Direction: " + (RightToLeft ? "right-to-left" : "left-to-right")); Debug.WriteLine("Firstchars: " + (FCPrefix == null ? "n/a" : RegexCharClass.SetDescription(FCPrefix.GetValueOrDefault().Prefix))); Debug.WriteLine("Prefix: " + (BMPrefix == null ? "n/a" : RegexParser.Escape(BMPrefix.ToString()))); Debug.WriteLine("Anchors: " + RegexFCD.AnchorDescription(Anchors)); Debug.WriteLine(""); if (BMPrefix != null) { Debug.WriteLine("BoyerMoore:"); Debug.WriteLine(BMPrefix.Dump(" ")); } for (i = 0; i < Codes.Length;) { Debug.WriteLine(OpcodeDescription(i)); i += OpcodeSize(Codes[i]); } Debug.WriteLine(""); }