diff --git a/novelwriter/core/coretools.py b/novelwriter/core/coretools.py index a4b2a0b1..85341f0e 100644 --- a/novelwriter/core/coretools.py +++ b/novelwriter/core/coretools.py @@ -289,7 +289,7 @@ class DocSearch: def __init__(self) -> None: self._regEx = re.compile(r"") - self._opts = re.UNICODE | re.IGNORECASE + self._opts = re.IGNORECASE self._words = False self._escape = True return @@ -300,9 +300,7 @@ class DocSearch: def setCaseSensitive(self, state: bool) -> None: """Set the case sensitive search flag.""" - self._opts = re.UNICODE - if not state: - self._opts |= re.IGNORECASE + self._opts = 0 if state else re.IGNORECASE return def setWholeWords(self, state: bool) -> None: diff --git a/novelwriter/formats/todocx.py b/novelwriter/formats/todocx.py index 366191ef..78aaf71d 100644 --- a/novelwriter/formats/todocx.py +++ b/novelwriter/formats/todocx.py @@ -51,7 +51,7 @@ if TYPE_CHECKING: logger = logging.getLogger(__name__) # RegEx -RX_TEXT = re.compile(r"([\n\t])", re.UNICODE) +RX_TEXT = re.compile(r"([\n\t])") # Types and Relationships OOXML_SCM = "http://schemas.openxmlformats.org" diff --git a/novelwriter/gui/dochighlight.py b/novelwriter/gui/dochighlight.py index 8103fd79..8bdb84de 100644 --- a/novelwriter/gui/dochighlight.py +++ b/novelwriter/gui/dochighlight.py @@ -139,7 +139,7 @@ class GuiDocHighlighter(QSyntaxHighlighter): # Multiple or Trailing Spaces if CONFIG.showMultiSpaces: - rxRule = re.compile(r"[ ]{2,}|[ ]*$", re.UNICODE) + rxRule = re.compile(r"[ ]{2,}|[ ]*$") hlRule = { 0: self._hStyles["mspaces"], } @@ -148,7 +148,7 @@ class GuiDocHighlighter(QSyntaxHighlighter): self._cmnRules.append((rxRule, hlRule)) # Non-Breaking Spaces - rxRule = re.compile(f"[{nwUnicode.U_NBSP}{nwUnicode.U_THNBSP}]+", re.UNICODE) + rxRule = re.compile(f"[{nwUnicode.U_NBSP}{nwUnicode.U_THNBSP}]+") hlRule = { 0: self._hStyles["nobreak"], } @@ -226,7 +226,7 @@ class GuiDocHighlighter(QSyntaxHighlighter): self._cmnRules.append((rxRule, hlRule)) # Alignment Tags - rxRule = re.compile(r"(^>{1,2}|<{1,2}$)", re.UNICODE) + rxRule = re.compile(r"(^>{1,2}|<{1,2}$)") hlRule = { 1: self._hStyles["markup"], } @@ -234,7 +234,7 @@ class GuiDocHighlighter(QSyntaxHighlighter): self._txtRules.append((rxRule, hlRule)) # Auto-Replace Tags - rxRule = re.compile(r"<(\S+?)>", re.UNICODE) + rxRule = re.compile(r"<(\S+?)>") hlRule = { 0: self._hStyles["replace"], } diff --git a/novelwriter/text/patterns.py b/novelwriter/text/patterns.py index a5d2b3e9..e0231d78 100644 --- a/novelwriter/text/patterns.py +++ b/novelwriter/text/patterns.py @@ -37,13 +37,13 @@ class RegExPatterns: # Static RegExes _rxUrl = re.compile(nwRegEx.URL, re.ASCII) - _rxWords = re.compile(nwRegEx.WORDS, re.UNICODE) - _rxBreak = re.compile(nwRegEx.BREAK, re.UNICODE) - _rxItalic = re.compile(nwRegEx.FMT_EI, re.UNICODE) - _rxBold = re.compile(nwRegEx.FMT_EB, re.UNICODE) - _rxStrike = re.compile(nwRegEx.FMT_ST, re.UNICODE) - _rxSCPlain = re.compile(nwRegEx.FMT_SC, re.UNICODE) - _rxSCValue = re.compile(nwRegEx.FMT_SV, re.UNICODE) + _rxWords = re.compile(nwRegEx.WORDS) + _rxBreak = re.compile(nwRegEx.BREAK) + _rxItalic = re.compile(nwRegEx.FMT_EI) + _rxBold = re.compile(nwRegEx.FMT_EB) + _rxStrike = re.compile(nwRegEx.FMT_ST) + _rxSCPlain = re.compile(nwRegEx.FMT_SC) + _rxSCValue = re.compile(nwRegEx.FMT_SV) @property def url(self) -> re.Pattern: @@ -108,7 +108,7 @@ class RegExPatterns: rx.append(f"(?:{qO}[^{qO}]+{qC})") if CONFIG.allowOpenDial: rx.append(f"(?:{qO}.+?$)") - return re.compile("|".join(rx), re.UNICODE) + return re.compile("|".join(rx)) return None @property @@ -118,7 +118,7 @@ class RegExPatterns: qO = re.escape(compact(CONFIG.altDialogOpen)) qC = re.escape(compact(CONFIG.altDialogClose)) qB = r"\B" if (qO == qC or qC in self.AMBIGUOUS) else "" - return re.compile(f"{qO}.*?{qC}{qB}", re.UNICODE) + return re.compile(f"{qO}.*?{qC}{qB}") return None @@ -163,8 +163,8 @@ class DialogParser: # Build narrator break RegExes if narrator := CONFIG.narratorBreak.strip()[:1]: punct = re.escape(".,:;!?") - self._breakD = re.compile(f"{narrator}.*?(?:{narrator}[{punct}]?|$)", re.UNICODE) - self._breakQ = re.compile(f"{narrator}.*?(?:{narrator}[{punct}]?)", re.UNICODE) + self._breakD = re.compile(f"{narrator}.*?(?:{narrator}[{punct}]?|$)") + self._breakQ = re.compile(f"{narrator}.*?(?:{narrator}[{punct}]?)") self._narrator = narrator self._mode = f" {narrator}"