Skip to content

Rework chunk-based replacer to work with less collision-prone pattern matching - #48

Open
Black-Platypus wants to merge 1 commit into
AUTOMATIC1111:masterfrom
Black-Platypus:pattern-replacer
Open

Rework chunk-based replacer to work with less collision-prone pattern matching#48
Black-Platypus wants to merge 1 commit into
AUTOMATIC1111:masterfrom
Black-Platypus:pattern-replacer

Conversation

@Black-Platypus

Copy link
Copy Markdown

The current "chunk" based replacer trips up on false positives:
Imagine a LoRA has two underscores. The wildcard replacer splits up the text, gets a nonsense chunk, can't find a matching wildcard file, returns "the original text". Doesn't sound so bad, but the LoRA will now fail to load because it's missing the two underscores.

To prevent this and further complications, depending on other features, I've switched to a RegEx based approach that should more closely capture syntax representing intent to replace wildcards.

  • Matches "(wildcard)" only if there are word boundaries around the underscores (and there is no whitespace within)
    \b__([^\s\r\n]+?)__\b
  • Only send matches to be replaced, obviously ^^

image

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant