comby-tools/comby

Different behavior from console and comby.live on matches with non-alphabetical characters

moonbaseDelta opened this issue · 3 comments

I'm trying to clear out javadoc-comments from some .java-files. That works as charm in comby.live ( example run - bit.ly/3qTiVwZ ), but from toml-config I get just weird results whatever I write for rewrite param (even if it was deleted), for instance:

[pattern]
match="/**:[javadoc]*/"
rewrite=""

The command I use is (matcher flag gives no difference):
comby -config config.toml -f file.java -matcher .java

Same situation is found for "//:[comment\n]" so it seems to be a bug with escaping or interpreting special characters.

Hey! So that comby.live example is using the generic matcher. Could you let me know if this works for you?

comby -config config.toml -f file.java -matcher .generic -match-newline-at-toplevel

In this case you probably want to use generic for clearing out comments, because the Java matcher will explicitly ignore them. They won't be matchable, unless you use a (more complex) regex hole, where you can do something like this.

Thanks. first part started to work, but for regex I got: Error in config.toml at line 6 at column 19 (position 83): Forbidden escaped char

Content:

...
[pattern1]
match=":[comment~^\s+//(.*)(?=\n)]"
rewrite=""

I should have reading docs better.
.toml does require one to write escape-chars

...
[pattern1]
match=":[comment~^\\s+//(.*)(?=\\n)]"
rewrite=""