Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

In regex plugin of gedit, I use a regex to match/search and another for substitution. In the matching regex, I only have one group. In the substitution regex, I use \1 to refer to the group, and I also like to add a zero right behind \1, but \10 will change to mean the 10th group in matching regex. So I was wondering how to solve this problem?

For example, in my original text there are cases where 0 is misinput as o, such as 12o should be 120. My matching regex is (\d+)o, and my substitution regex is \10 which is not right.

share|improve this question
    
It depends on the regexp engine. Which plugin are you using (there are several around)? –  Gilles Jul 15 '11 at 18:02
    
It is Python-style regex, written by Daniel d'Andrada T. de Carvalho <daniel.carvalho@indt.org.br>, Ben Fisher halfhourhacks.blogspot.com –  Tim Jul 15 '11 at 18:14
    
\1[0] should do it in pretty much every implementation. (So that's a character class consisting of a single character, without quantifiers like ? or *.) –  janmoesen Nov 6 '11 at 20:16
add comment

1 Answer

up vote 2 down vote accepted

Assuming that plugin uses the same syntax as the Python regexp engine: use \g<1>0 as the replacement text.

share|improve this answer
    
thanks a lot for that one! –  user871784 Sep 3 '13 at 10:40
add comment

Your Answer

 
discard

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.