public void RemoveAllWaggons() { var matchRegExResponse = _regexService.MatchRegex(_model.FileContent); if (matchRegExResponse.HasMatched) { _model.FileContent = _regexService.Replace( _model.FileContent, matchRegExResponse.Prefix + matchRegExResponse.Suffix, matchRegExResponse.MatchingRegEx); } }
public void Move() { var matchRegExResponse = _regExService.MatchRegex(_mainModel.FileContent); if (!matchRegExResponse.HasMatched) { return; } var regex = new Regex(@"^(.*,\d,)(-?\d*(?:\.\d*)?)_(-?\d(?:\.\d*)?)_(-?\d*(?:\.\d*)?)(,.*)", RegexOptions.Multiline); var someObjects = matchRegExResponse.Content.Split("%"); for (var i = 0; i < someObjects.Length; i++) { var match = regex.Match(someObjects[i]); var leadingValue = match.Groups[1].Value; var x = _parseAndAddFloatValue.For(match.Groups[2].Value, _mainModel.MoveXAxisValue); var y = _parseAndAddFloatValue.For(match.Groups[3].Value, _mainModel.MoveYAxisValue); var z = _parseAndAddFloatValue.For(match.Groups[4].Value, _mainModel.MoveZAxisValue); var trailingValue = match.Groups[5].Value; someObjects[i] = someObjects[i].Replace(match.Value, $"{leadingValue}{x}_{y}_{z}{trailingValue}"); //someObjects[i] = $"{leadingValue}{x}_{y}_{z}{trailingValue}"; } var result = string.Join("%", someObjects); _mainModel.FileContent = _regExService.Replace(_mainModel.FileContent, matchRegExResponse.Prefix + result + matchRegExResponse.Suffix, matchRegExResponse.MatchingRegEx); }