Among the joys of KDE, Kwrite is surely noteworthy. Having regular expression support built in by default into text editor is probably one of the top 10 best ideas of all time. Since I often need to do a lot of finding and replacing, I have already begun to save a lot of time and hassle by using Kwrite.

I suppose it's probably a lot like in sed, but anyway, I am matching stuff like


using the simple regex [a-z][0-9]. How do I then tell kwrite to replace the text using the first part of the regex? Using [a-z] in the 'replace' box gives things like 'numbersdonot[a-z]' as a result. But I want,



Find: ([a-z])[0-9]
Replace: \1

Parenthesis save content matched and can be used with expression \<number> depending of how many parenthesis used in the Find expression and its order from the beginning.

For example, if you wanted to change order between the letter and the number, would be:

Find: ([a-z])([0-9])
Replace: \2\1
  • today, the universe is a more beautiful place. – ixtmixilix Dec 29 '11 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.