| 1908 | 1908 | * @returns {string} The html representation of the highlighted regex |
| 1909 | 1909 | */ |
| 1910 | 1910 | export function highlightRegex(regexStr) { |
| 1911 | 1911 | // Function to escape HTML special characters for safety or readability |
| 1912 | 1912 | const escapeHtmlescape = (str) => str.replace(/[&<>"'\x01]/g, match => ({ |
| 1913 | 1913 | '&': '&', '<': '<', '>': '>', '"': '"', '\'': ''', '\x01': '\\x01', |
| 1914 | 1914 | })[match]); |
| 1915 | 1915 | |
| 1916 | 1916 | // Replace special characters with their HTML-escaped forms |
| 1917 | 1917 | regexStr = escapeHtmlescape(regexStr); |
| 1918 | 1918 | |
| 1919 | 1919 | // Patterns that we want to highlight only if they are not escaped |
| 1920 | 1920 | function getPatterns() { |