Krename and spaces

Hello,
I am using krename to rename files from something like aaa_bbbb to aaa bbb, that is, to replace the underscore with a space. This works ok if I enter the space manually in the interface.
However, I have saved the renaming scheme (which is more complex, as it contains other manipulations). When I load the saved scheme and try to apply it, the substitution does not work: the underscore is deleted, but it is not replaced with a space. Also, the space is not present in its interface field after loading the renaming scheme. It is as if upon loading the renaming scheme, the space is ignored.
My question is if there is a way to make the space be inserted correctly after reloading the scheme, other than manually inputting it in the interface.

I am on KDE Neon, up to date.

Thanks

I’m assuming that only having the space in the Replace With: field without any other text surrounding it (or anything else generally) is what’s causing the problem. I have perhaps an odd solution, which I’ve tested, that uses a regular expression, which you could test yourself to see if it works for you.

  • Create a Find and Replace... item
  • Tick Find is a Regular Expression
  • Tick Process tokens in replace string
  • In the Find: field, enter (.?)_+(.?)
  • In the Replace With: field, enter \1 \2 (with a space between the tokens)
  • Confirm if this works and save the settings that include this item in it.

I don’t know how familiar you are with regular expressions, but to provide some explanation just in case you aren’t familiar or other people are interested, for the regex:

  • The (.?) matches zero or one occurrence of any character, so whether or not there’s a single character before or after the underscore, it should match.
    • Additionally having the parentheses () around the match captures whatever matches.
  • The _+ matches one or more occurrences of the underscore character.
  • The combined Find: regex is looking for zero or one instance of any character, before and after one or more underscore characters. It’s also capturing the zero or one instance of any character, both before and after.
  • In the Replace With: field, the captured matches can be output in the replaced text and are the tokens represented with a slash followed by the capture number in order, so \1 is the token matching the first capture (before the underscore) and \2 is the token matching the second capture (after the underscore).

Using a variant of your example let’s say you have aaZ_Abbbb, it’s matching the Z_A portion, capturing the Z and the A matches, then replacing Z_A with the Z, a space, then the A so the matching portion becomes Z A and the replaced text should be aaZ Abbbb.

I’m pretty sure this should do what you need and since the space in the Replace With: is surrounded by other text (which is where I think part of the issue lies), it ensure that you can save the the Find and Replace... settings.

This is working as intended.
Thank you very much.