Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

I am trying to use Regex Search & Replace plugin of gedit.

  1. I want to search a digit that repeats 2 or 3 times, so I thought the regex was


    But it doesn't match the target it should such as "22".

  2. I want to find a word "Notes" exactly, so I thought it would be


    But it doesn't work either.

  3. How to add a "#" in front of a string of any three digits "[0-9][0-9][0-9]"? e.g. "123" becomes "#123".

I was wondering if I made some mistake? I am using Basic Regex. What type of Regex is used in the plugin? Could you provide a link for me to be familiar with it?

Thanks and regards!

share|improve this question
up vote 14 down vote accepted

You should not need to escape your regex characters. Your first example should be:


Your second example should be:


For the third situation, you'll need to match things before and after, then use back-references:


with the replacement being:


For more details, see pydoc re that will tell you about Python regular expression syntax, or the online documentation:

share|improve this answer

As Kees says, the plugin uses Python's re module syntax, which also has a How-To on the python site.

I also recommend installing and playing around with kodos Install kodos .
It's a python regular expression tester (it calls itself a 'debugger'), and includes a quick reference regex sheet as well as a shorter version of the re module documentation.

The site has a nice comparison of different implementations of regular expression meta-languages. There's a decent section on the python flavor there as well.

share|improve this answer
@igbelacqua: Thanks! I guess Kodos is for KDE. If I am correct, it can be installed on Gnome but not the best if there is some other native software for Gnome. Do you know what the natives are? – Tim Mar 15 '11 at 13:24
Hmm -- Kodos does have Qt dependencies, but it's not a KDE app per se that I can see. I run basic Ubuntu (Gnome), and it hasn't been out of place . Another option is kiki -- it's a python-wxgtk2.6 application -- not as full-featured. I used it before finding kodos. Another tester option that doesn't require an install is -- it says it was inspired by Kodos, and it's clean and useful. It's possibly the easiest to use of the three. – belacqua Mar 15 '11 at 18:55

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.