Closed frankcollins3 closed 1 year ago
also the establishing of </div>
should be performed on {quantity}:
the newly declared string to which .Remove() && .Replace() have already applied.
[6:07pm]
for this code:
void stringMutation()
{
int openingDivLessThan = input.IndexOf("<");
int openingDivGreaterThan = input.IndexOf(">");
openingDivGreaterThan += 1;
// doesn't need the +1 as it is the last character in the string.
quantity = input.Remove(openingDivLessThan, openingDivGreaterThan);
int closingDivLessThan = quantity.LastIndexOf("<");
int closingDivGreaterThan = quantity.LastIndexOf(">");
quantity = input.Remove(closingDivLessThan, closingDivGreaterThan);
// quantity = input.Remove(closingDivLessThan, closingDivGreaterThan);
quantity = quantity.Replace("&trade", "®");
}
➜ TestProject git:(master) ✗ dotnet run Unhandled exception. System.ArgumentOutOfRangeException: Index and count must refer to a location within the string. (Parameter 'count') at System.String.Remove(Int32 startIndex, Int32 count) [6:09pm]
tangled up. going to run logs and do a hardcoding .Remove() of </div>
instead of working expression.
[6:12pm]
code: output: [6:24pm]
attempting to do: remove the closing
</div>
tag from the stringerror: range/out-of-bounds limit
proposed approach: if correct, neat issue where the problem is. the initial finding of the index is done before any .remove() finding the closing tag should be done after the first .Remove() statement eliminates the opening
<div>
// last assumption on a separate index related problem was wrong so this could be wrong too.
possible improvements: