Author Topic: [v1.7.3.1] "ExtractPhrases" always trims whitespace if dynamic sections exist  (Read 1319 times)

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
The added overload for the "ExtractPhrases" method does not respect the "optionalBooleanTrimSpaces" parameter if an opening square bracket is present within "stringPhrases":

Code: [Select]
foreach (string s in VA.ExtractPhrases("   tEsT                 ;  test  ;  tes   t", false, false))
{
VA.WriteToLog(s.Length.ToString());
}
will write "25", "8", and "9" to the log(the "Length" property is used as what is written to the log also has its whitespace trimmed)

whereas
Code: [Select]
foreach (string s in VA.ExtractPhrases("   tEsT                 ;  test  ;  tes   t[", false, false))
{
VA.WriteToLog(s.Length.ToString());
}
will write "4", "4", and "5" to the log, as even mid-string whitespace will have been trimmed.


I assume the parser for dynamic sections always trims whitespace when it is called. Perhaps mentioning this caveat in the documentation would suffice?


EDIT: Noted in the documentation for v1.7.3.2
« Last Edit: February 17, 2019, 12:35:20 AM by Pfeil »

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Thanks for the heads up - I'll put that in the doc, as the dynamic command parser (in which your second example's text absolutely gets handed off) does trim spaces out.  I'm not going to overload that function with yet another boolean to see if the trim should be ignored (99.99999999% of the time it wont).  The optional parameter was added to fill a request without possibly breaking somebody's function out there that may be relying on it (for whatever reason that would be).