2

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

numbersdonot8
belongattheend0
ofwords2

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,

numbersdonot
belongattheend
ofwords
Rui F Ribeiro
  • 55,929
  • 26
  • 146
  • 227
ixtmixilix
  • 13,040
  • 27
  • 82
  • 118

1 Answers1

3

Try:

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
Birei
  • 7,924
  • 2
  • 22
  • 14