From 7278d104cf7303f6e16eac82212066d80e20d4bc Mon Sep 17 00:00:00 2001 From: ivandrofly Date: Fri, 29 May 2015 23:53:42 +0100 Subject: [PATCH] Regex: Two more regex added to context menu + multi-lang support --- LanguageMaster.xml | 2 ++ src/Logic/FindReplaceDialogHelper.cs | 4 ++++ src/Logic/Language.cs | 2 ++ src/Logic/LanguageDeserializer.cs | 6 ++++++ src/Logic/LanguageStructure.cs | 10 ++++++---- 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/LanguageMaster.xml b/LanguageMaster.xml index 8203ad21c..a71fe8191 100644 --- a/LanguageMaster.xml +++ b/LanguageMaster.xml @@ -1421,8 +1421,10 @@ can edit in same subtitle file (collaboration) New line (\r\n) New line (\n) Any digit (\d) + Non digit (\D) Any character (.) Any whitespace (\s) + Non space character (\S) Zero or more (*) One or more (+) In character group ([test]) diff --git a/src/Logic/FindReplaceDialogHelper.cs b/src/Logic/FindReplaceDialogHelper.cs index 22d094711..d9dd4022c 100644 --- a/src/Logic/FindReplaceDialogHelper.cs +++ b/src/Logic/FindReplaceDialogHelper.cs @@ -153,8 +153,10 @@ namespace Nikse.SubtitleEdit.Logic cm.MenuItems.Add(l.NonWordBoundary, delegate { textBox.SelectedText = "\\B"; }); cm.MenuItems.Add(l.NewLine, delegate { textBox.SelectedText = "\\r\\n"; }); cm.MenuItems.Add(l.AnyDigit, delegate { textBox.SelectedText = "\\d"; }); + cm.MenuItems.Add(l.NonDigit, delegate { textBox.SelectedText = "\\D"; }); cm.MenuItems.Add(l.AnyCharacter, delegate { textBox.SelectedText = "."; }); cm.MenuItems.Add(l.AnyWhitespace, delegate { textBox.SelectedText = "\\s"; }); + cm.MenuItems.Add(l.NonSpaceCharacter, delegate { textBox.SelectedText = "\\S"; }); cm.MenuItems.Add(l.ZeroOrMore, delegate { textBox.SelectedText = "*"; }); cm.MenuItems.Add(l.OneOrMore, delegate { textBox.SelectedText = "+"; }); cm.MenuItems.Add(l.InCharacterGroup, delegate { textBox.SelectedText = "[test]"; }); @@ -170,8 +172,10 @@ namespace Nikse.SubtitleEdit.Logic cm.MenuItems.Add(l.NonWordBoundary, delegate { comboBox.SelectedText = "\\B"; }); cm.MenuItems.Add(l.NewLine, delegate { comboBox.SelectedText = "\\r\\n"; }); cm.MenuItems.Add(l.AnyDigit, delegate { comboBox.SelectedText = "\\d"; }); + cm.MenuItems.Add(l.NonDigit, delegate { comboBox.SelectedText = "\\D"; }); cm.MenuItems.Add(l.AnyCharacter, delegate { comboBox.SelectedText = "."; }); cm.MenuItems.Add(l.AnyWhitespace, delegate { comboBox.SelectedText = "\\s"; }); + cm.MenuItems.Add(l.NonSpaceCharacter, delegate { comboBox.SelectedText = "\\S"; }); cm.MenuItems.Add(l.ZeroOrMore, delegate { comboBox.SelectedText = "*"; }); cm.MenuItems.Add(l.OneOrMore, delegate { comboBox.SelectedText = "+"; }); cm.MenuItems.Add(l.InCharacterGroup, delegate { comboBox.SelectedText = "[test]"; }); diff --git a/src/Logic/Language.cs b/src/Logic/Language.cs index e99554c9a..c9149fbba 100644 --- a/src/Logic/Language.cs +++ b/src/Logic/Language.cs @@ -1686,7 +1686,9 @@ can edit in same subtitle file (collaboration)", NewLine = "New line (\\r\\n)", NewLineShort = "New line (\\n)", AnyDigit = "Any digit (\\d)", + NonDigit = "Non digit (\\D)", AnyCharacter = "Any character (.)", + NonSpaceCharacter = "Non space character (\\S)", AnyWhitespace = "Any whitespace (\\s)", ZeroOrMore = "Zero or more (*)", OneOrMore = "One or more (+)", diff --git a/src/Logic/LanguageDeserializer.cs b/src/Logic/LanguageDeserializer.cs index 463568ecb..0431bc742 100644 --- a/src/Logic/LanguageDeserializer.cs +++ b/src/Logic/LanguageDeserializer.cs @@ -3771,12 +3771,18 @@ namespace Nikse.SubtitleEdit.Logic case "RegularExpressionContextMenu/AnyDigit": language.RegularExpressionContextMenu.AnyDigit = reader.Value; break; + case "RegularExpressionContextMenu/NonDigit": + language.RegularExpressionContextMenu.NonDigit = reader.Value; + break; case "RegularExpressionContextMenu/AnyCharacter": language.RegularExpressionContextMenu.AnyCharacter = reader.Value; break; case "RegularExpressionContextMenu/AnyWhitespace": language.RegularExpressionContextMenu.AnyWhitespace = reader.Value; break; + case "RegularExpressionContextMenu/NonSpaceCharacter": + language.RegularExpressionContextMenu.NonSpaceCharacter = reader.Value; + break; case "RegularExpressionContextMenu/ZeroOrMore": language.RegularExpressionContextMenu.ZeroOrMore = reader.Value; break; diff --git a/src/Logic/LanguageStructure.cs b/src/Logic/LanguageStructure.cs index d40d3eb28..52e4774bc 100644 --- a/src/Logic/LanguageStructure.cs +++ b/src/Logic/LanguageStructure.cs @@ -191,11 +191,11 @@ public string SetMinMsBetweenSubtitles { get; set; } public string PlainText { get; set; } public string Ocr { get; set; } - public string Filter { get; set; } - public string FilterSkipped { get; set; } + public string Filter { get; set; } + public string FilterSkipped { get; set; } public string FilterSrtNoUtf8BOM { get; set; } - public string FilterMoreThanTwoLines { get; set; } - public string FilterContains { get; set; } + public string FilterMoreThanTwoLines { get; set; } + public string FilterContains { get; set; } public string FixCommonErrorsErrorX { get; set; } public string MultipleReplaceErrorX { get; set; } public string AutoBalanceErrorX { get; set; } @@ -1570,8 +1570,10 @@ public string NewLine { get; set; } public string NewLineShort { get; set; } public string AnyDigit { get; set; } + public string NonDigit { get; set; } public string AnyCharacter { get; set; } public string AnyWhitespace { get; set; } + public string NonSpaceCharacter { get; set; } public string ZeroOrMore { get; set; } public string OneOrMore { get; set; } public string InCharacterGroup { get; set; }