Use RegexOption.SingleLine to handle transitions to sections which have embedded carriage returns in the section title.

This commit is contained in:
Rich 2015-04-28 16:09:26 +00:00
parent 0ac678ebda
commit 2b47b33ba2
3 changed files with 6 additions and 6 deletions

View File

@ -36,7 +36,7 @@ namespace VEPROMS.CSLA.Library
if (forceConvertToText) if (forceConvertToText)
newvalue = "?"; newvalue = "?";
string findLink = @"<START\].*?\[END>"; string findLink = @"<START\].*?\[END>";
MatchCollection ms = Regex.Matches(Text, findLink); MatchCollection ms = Regex.Matches(Text, findLink, RegexOptions.Singleline);
//string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID); //string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
string lookFor; string lookFor;
if (tran == null) if (tran == null)

View File

@ -229,7 +229,7 @@ namespace Volian.Controls.Library
} }
private bool InLinkedText(string text, int idx) private bool InLinkedText(string text, int idx)
{ {
MatchCollection mc = Regex.Matches(text, @"<START\].*?\[END>"); MatchCollection mc = Regex.Matches(text, @"<START\].*?\[END>", RegexOptions.Singleline);
if (mc.Count == 0) return false; if (mc.Count == 0) return false;
foreach (Match m in mc) foreach (Match m in mc)
if (m.Index < idx && m.Index + m.Length > idx) return true; if (m.Index < idx && m.Index + m.Length > idx) return true;
@ -1958,7 +1958,7 @@ namespace Volian.Controls.Library
{ {
if (_TextAndLink != null) if (_TextAndLink != null)
{ {
Match m = Regex.Match(_TextAndLink, @"<START\](\\[^v \\]+)*\\v0(\\[^v'?{}~ \\]+)*( |\\u[0-9]{{1,4}}?|\\'[0-9a-fA-F]{{2}}|\\[{{}}~])(.*?)(\\[^v'?{}~ \\]+)*\\v(\\[^v \\]+)* #Link:(.*?)\[END>"); Match m = Regex.Match(_TextAndLink, @"<START\](\\[^v \\]+)*\\v0(\\[^v'?{}~ \\]+)*( |\\u[0-9]{{1,4}}?|\\'[0-9a-fA-F]{{2}}|\\[{{}}~])(.*?)(\\[^v'?{}~ \\]+)*\\v(\\[^v \\]+)* #Link:(.*?)\[END>", RegexOptions.Singleline);
if(m.Groups[3].Value == " ") if(m.Groups[3].Value == " ")
return m.Groups[4].Value; return m.Groups[4].Value;
return m.Groups[3].Value + m.Groups[4].Value; return m.Groups[3].Value + m.Groups[4].Value;
@ -1969,7 +1969,7 @@ namespace Volian.Controls.Library
{ {
if (_TextAndLink != null) if (_TextAndLink != null)
{ {
Match m = Regex.Match(_TextAndLink, @"<START\](\\[^v \\]+)*\\v0(\\[^v'?{}~ \\]+)*( |\\u[0-9]{{1,4}}?|\\'[0-9a-fA-F]{{2}}|\\[{{}}~])(.*?)(\\[^v'?{}~ \\]+)*\\v(\\[^v \\]+)* #Link:(.*?)\[END>"); Match m = Regex.Match(_TextAndLink, @"<START\](\\[^v \\]+)*\\v0(\\[^v'?{}~ \\]+)*( |\\u[0-9]{{1,4}}?|\\'[0-9a-fA-F]{{2}}|\\[{{}}~])(.*?)(\\[^v'?{}~ \\]+)*\\v(\\[^v \\]+)* #Link:(.*?)\[END>", RegexOptions.Singleline);
int myIndex = m.Groups[4].Index; int myIndex = m.Groups[4].Index;
int myLength = m.Groups[4].Length; int myLength = m.Groups[4].Length;
if (m.Groups[3].Value != " ") if (m.Groups[3].Value != " ")

View File

@ -2888,7 +2888,7 @@ namespace Volian.Controls.Library
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
int lastIndex = 0; int lastIndex = 0;
MatchCollection mc = Regex.Matches(line, @"<START\](.*?)#Link.*?\[END>"); MatchCollection mc = Regex.Matches(line, @"<START\](.*?)#Link.*?\[END>", RegexOptions.Singleline);
foreach (Match m in mc) foreach (Match m in mc)
{ {
sb.Append(line.Substring(lastIndex, m.Index - lastIndex)); // Append text before the link sb.Append(line.Substring(lastIndex, m.Index - lastIndex)); // Append text before the link
@ -2914,7 +2914,7 @@ namespace Volian.Controls.Library
string lineAbove = RemoveLinkComments(Lines[row-1]); string lineAbove = RemoveLinkComments(Lines[row-1]);
string lineBelow = RemoveLinkComments(Lines[row+1]); string lineBelow = RemoveLinkComments(Lines[row+1]);
int rowOffset = GetFirstCharIndexFromLine(row); int rowOffset = GetFirstCharIndexFromLine(row);
MatchCollection matchCollection = Regex.Matches(line, @"<START\](.*?)#Link.*?\[END>"); //, RegexOptions.Singleline); MatchCollection matchCollection = Regex.Matches(line, @"<START\](.*?)#Link.*?\[END>", RegexOptions.Singleline);// this last parameter was commented out in 7/24/09 but it appears to be valid
if (matchCollection.Count == 0) matchCollection = Regex.Matches(line, @"<START\]"); if (matchCollection.Count == 0) matchCollection = Regex.Matches(line, @"<START\]");
if (matchCollection.Count == 0) matchCollection = Regex.Matches(line, @"#Link.*?\[END>"); if (matchCollection.Count == 0) matchCollection = Regex.Matches(line, @"#Link.*?\[END>");
Match match = matchCollection.Count > 0 ? matchCollection[0] : null; Match match = matchCollection.Count > 0 ? matchCollection[0] : null;