Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

Just one problem: I'm still a newbie at it. 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,

share|improve this question
up vote 2 down vote accepted


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
share|improve this answer
today, the universe is a more beautiful place. – ixtmixilix Dec 29 '11 at 15:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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