This is not a bug, it is just the way it is. Almost every single line field in the Mac will not accept pressed returns, but most will accept pasted returns, and such returns will result in largely invisible text in there.
This is really no different to a replacement text that has spaces at the end.
There is nothing wrong with having a return character in your replacement text.
I mean, using the (?x) flag, you can paste in commented regexes like this (like, say, you found something you could use on StackOverflow or elsewhere):
# Match a 20th or 21st century date in yyyy-mm-dd format
(19|20)\d\d # year (group 1)
[- /.] # separator
(0[1-9]|1) # month (group 2)
[- /.] # separator
(0[1-9]|[0-9]|3) # day (group 3)
and only one line at a time would show in KM. And you can't even type that regex in at all because you can't type multiple lines. That doesn't seem like the way things should be.
Or it would even be useful to be able to type in multiple line replacement patterns.
And, really, that kinda reduces the utility of the (?x) flag. You can't really take full advantage of it because you either can't type in multiple lines or will only see one line at a time of a pasted-in pattern, which makes it difficult to study a pattern as a whole.
Well, Peter, I hope you can appreciate how this can cause serious problems for the user.
Both myself and @Isak were completely confused and mislead by this behavior, which resulted in considerable wasted time. For me, at least an hour. Not acceptable for a tool that is supposed to SAVE me time.
Evidently you do know how to design a single-line text field so that it only accepts one line:
The "Set Variable to Text" Action:
Note how the Variable name is displayed in RED, and nothing is actually entered for the Variable Name.
When I run the below macro, I get this:
So, surely it is clear to you that some change is needed on the Search and Replace and Search with Regex Actions to address this issue.
At the bare minimum, I suggest that you treat both the "Search for" and "Replace with" fields the same as you do with the "Set Variable to Text" Action.
OTOH, I agree with @roosterboy above, that accepting multiple lines in these fields could be useful.
If you do accept multiple lines, then the field should auto-expand to show ALL lines.
Thanks for your consideration of this change request.