How to find parts of currency that use dots as group separator (look at Unit Price column in DatagridView) with regex?

When I typed the number 100 in the search Text Box, the numbers 1.00 in the Unit Price column (the number in the red box) was not selected. I want that numbers 1.00 to be selected (yellow color).
The above results are from the following code:
private async Task AddProduct_DataGridView_CellPaintingAsync(object sender, DataGridViewCellPaintingEventArgs e) { try { if (e.RowIndex < 0 || e.ColumnIndex < 0) { return; } // draw empty background e.PaintBackground(e.ClipBounds, true); // draw default content e.PaintContent(e.ClipBounds); // search String String searchString = AddProduct_SearchTextBox.Text; if (String.IsNullOrEmpty(searchString)) { return; } // cell String String? cellValue = e.FormattedValue.ToString(); if (String.IsNullOrEmpty(cellValue)) { return; } // unit price if (e.ColumnIndex == 2) { //??? } // search searchString in cellValue MatchCollection? searchPositions = Regex.Matches(cellValue, searchString); if (searchPositions is null) { return; } if (searchPositions.Count == 0) { return; } // construct a StringFormat object. using (StringFormat cellFormat = new StringFormat()) { // set the ranges on the StringFormat object. cellFormat.SetMeasurableCharacterRanges(searchPositions.OfType().Select(x => new CharacterRange(x.Index, x.Length)).ToArray()); // construct a new RectangleF. RectangleF rectF = new RectangleF(e.CellBounds.X + 0.8f, e.CellBounds.Y + 4.2f, e.CellBounds.Width + 0.0f, e.CellBounds.Height + 0.0f); using (Font cellFont = new Font("Microsoft Sans Serif", 10.5f, FontStyle.Regular)) { // get the Region to highlight by calling the MeasureCharacterRanges method. Region[] regions = e.Graphics.MeasureCharacterRanges(cellValue, cellFont, rectF, cellFormat); if (regions.Length == 0) { return; } // draw empty background e.PaintBackground(e.ClipBounds, true); foreach (Region? region in regions) { if (region is not null) { using (var lightBrush = new SolidBrush(Color.FromArgb(0xFF, Color.Yellow))) { // fill in the region using a semi-transparent color. e.Graphics.FillRegion(lightBrush, region); } } } // draw default content e.PaintContent(e.ClipBounds); } } // draw custom graphic content e.Handled = true; await Task.Yield(); } catch (Exception ex) { Log.Exception(ex); } } Thanks.
Источник: https://stackoverflow.com/questions/781 ... -separator
Мобильная версия