Skip to content

[Bug Report] Replace does nothing when trying to replace ",*" with nothing #2108

Open

Description

@ipswe

Hi

Trying to remove IPV6 IP-numbers in a list where there are both IPV4 and IPV6 in the same cell.

Works in Excel but in Gridcraft it reports a success but nothing happens. See below picture.

Image

BR

PJ

Activity

  1. ipswe commented on Oct 21, 2026

    @ipswe
    Author

    Version 0.9.0 on Windows 11

  2. iluebbe commented on Oct 22, 2026

    @iluebbe

    #2127 checked

    Fixes it. Replace with a * or ? pattern now replaces the text the pattern matches; ,* with nothing turns 10.0.0.1, fe80::1 into 10.0.0.1, as in Excel.

    Setup: PR head a8de4640 (the PR has since been rebased to 5fb58db1 with the same code change), main at 06920de, Windows 11. gridcraft-cli run with cell.set + edit.replace (the main binary and the PR build), compared with Excel for Microsoft 365 (16.0 build 20430) through COM (Range.Replace, part match).

    Cell Find → Replace main PR Excel
    10.0.0.1, fe80::1 ,* → nothing unchanged (replaced: 1) 10.0.0.1 10.0.0.1
    hello world h*o → X unchanged X world X world
    hello world l* → X unchanged heX heX
    xaxbyazb a?b → X unchanged xXyX xXyX
    a*b*c ~* → + unchanged a+b+c a+b+c
    Hello hello h?llo → X unchanged X X X X
    Hello hello h?llo → X, Match case unchanged Hello X Hello X
    a1, b2; c3 ,*; → | unchanged a1| c3 a1| c3
    ab-cd-ef -*- → + unchanged ab+ef ab+ef

    Other cases on the PR build (not measured in Excel): * → X replaces the whole text, ~? replaces a literal ?, b? on abcabc gives a_a_, a plain x → - still replaces literally (aXbxc → a-b-c). 200 cells of 32,767 × a with a*b: 0.58 s on the PR build, 0.68 s on main, so no slowdown.

    No problems found in the change.

    Merging: the rebased head 5fb58db1 is based on main at 06920de, so it merges without conflicts. The earlier head conflicted only in tests and contributors/people.toml.

    Tests: the three new tests pass; cargo test -p gridcraft-engine 348 passed, 0 failed; cargo clippy -p gridcraft-engine --all-targets -- -D warnings and cargo fmt --all -- --check are clean (on the PR head, not on the merge).

  3. luigiPinna commented on Oct 22, 2026

    @luigiPinna

    @iluebbe thanks for checking this against Excel through COM — the table covers more cases than the tests do. The rebased head 5fb58db1 carries the same change as a8de4640, so your results hold for it.

  4. iluebbe commented on Oct 28, 2026

    @iluebbe

    #2127 checked again

    Still fixes it. Since the first check, the wildcard Replace folds case as Find does (9515054), and main was merged in (last at 11bb673). Every wildcard Replace case tried gives Excel's result. The two differences left are ~ patterns that main handles the same way and that #1455 covers.

    Setup: PR head a6c2872, merged locally with main at 70327cd; main at 70327cd (0.13.0 release binaries); Windows 11. gridcraft-cli run with cell.set, edit.replace and edit.find (one new workbook per Replace case), compared with Excel for Microsoft 365 (16.0 build 20527) through COM: Range.Replace and Range.Find/FindNext on a new workbook, closed without saving.

    Earlier finding Now
    The nine cases of the first table match Excel: ,* with nothing on 10.0.0.1, fe80::1 gives 10.0.0.1; h*o, l*, a?b, ~*, h?llo with and without Match case, ,*;, -*- Still so, measured again on the merge
    No problems found in the change Still none

    New cases (part of the cell unless noted). On main every matching pattern with * or ? leaves the cell unchanged, though it counts the cell as replaced. The Match entire cell rows already worked on main:

    Cell Find → Replace PR Excel
    HELLO world h*o → X X world X world
    HELLO world h*o → X, Match case unchanged unchanged
    a?b?c ~? → + a+b+c a+b+c
    a~b*c ~~? → X aX*c aX*c
    a~b a~~* → X X X
    banana *a → X XXX XXX
    a,b,c *, → X XXc XXc
    a1b2a3b4 a*b* → X X X
    hello world * → X X X
    abc ? → X XXX XXX
    aXYb a**b → X X X
    hello world h*d / h*o / ?ELLO* → X, Match entire cell X / unchanged / X X / unchanged / X
    hello world ?ELLO* → X, Match entire cell and Match case unchanged unchanged
    12345 (number) 2?4 → X / 2*4 → 0 text 1X5 / number 105 text 1X5 / number 105
    ="ab"&"cd" b*c → X ="aXd" (shows aXd) ="aXd"
    ="xyz" x?z → Q ="Q" ="Q"
    ΚΑΛΟΣ λ?ς → X (9515054) ΚΑX ΚΑX
    a~b~c ~~ → + unchanged, as on main a+b+c
    ab~c b*~ → X unchanged, as on main aX

    Find (edit.find, unchanged by the PR) over ten cells, with h*o, h?llo (with and without Match case), ~*, ~?, a?b (entire cell), b*c (formulas and values), 3 (formulas and values), 2?4, h* and * (entire cell): the same cells as Excel, on main and on the PR. ~~ finds nothing, while Excel finds a~b.

    Problems: none in the change. The last two Replace rows and the ~~ Find differ from Excel as they do on main. A pattern without * or ? is still taken literally, and a trailing ~ escapes the * that matches appends (find.rs#L6-L14). Excel reads ~~ as one ~ and drops a trailing ~. Both rules are listed in #1455, and the PR description leaves them there.

    Merging: merges without conflicts with main at 70327cd.

    Tests: on the merge with main at 70327cd:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions