| | | 1 | | using System.Text.RegularExpressions; |
| | | 2 | | |
| | | 3 | | namespace DirectSight.Reporting.Builders.Rendering; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Helper methods for <see cref="string"/>. |
| | | 7 | | /// </summary> |
| | | 8 | | public static class StringHelper |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// Replaces the invalid chars in the given path. |
| | | 12 | | /// </summary> |
| | | 13 | | /// <param name="path">The path.</param> |
| | | 14 | | /// <returns>The path with replaced invalid chars.</returns> |
| | 36 | 15 | | public static string ReplaceInvalidPathChars(string path) => Regex.Replace(path, "[^\\w^\\.]", "_"); |
| | | 16 | | |
| | | 17 | | /// <summary> |
| | | 18 | | /// Replaces all non letter chars in the given string. |
| | | 19 | | /// </summary> |
| | | 20 | | /// <param name="text">The text.</param> |
| | | 21 | | /// <returns>The text with replaced invalid chars.</returns> |
| | 72 | 22 | | public static string ReplaceNonLetterChars(string text) => Regex.Replace(text, "[^\\w]", string.Empty); |
| | | 23 | | |
| | | 24 | | /// <summary> |
| | | 25 | | /// Replaces the invalid XML chars in the given string. |
| | | 26 | | /// </summary> |
| | | 27 | | /// <param name="text">The text.</param> |
| | | 28 | | /// <returns>The text with replaced invalid chars.</returns> |
| | 0 | 29 | | public static string ReplaceInvalidXmlChars(string text) => Regex.Replace(text, @"(?<![\uD800-\uDBFF])[\uDC00-\uDFFF |
| | | 30 | | } |