Super User is a question and answer site for computer enthusiasts and power users. 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 want to replace all the




What should I put in the search box?

share|improve this question
Should the output be four of "\caption{}" or only one? Should the numbers (1, 2, 3, 4) be extracted and put in the output? – Peter Mortensen Jun 3 '12 at 7:52
TextMate uses the Oniguruma regular expression library. Section 20.3 of the manual has information on the flavour of regular expressions TextMate is using and apparently there are some options in the user interface of TextMate to affect some behaviours of regular expression matching (Ruby, Perl, Java and Oniguruma style). – Peter Mortensen Jun 3 '12 at 8:26

You want to replace




As simple as that.

You need to have the backslash \ and the parentheses () escaped because they have a special meaning in regular expressions. The .* part matches any character, multiple times. This would match the ..2. substrings.

If you really want to exchange the parentheses to curly braces, you could add a capture group by adding () around the string you want to match, and then reusing it in your replacement:




The content of your first "caption" is captured in the first register, which we access with $1 again.

Please read the manual on TextMate regular expressions for more: TextMate Manual » Regular Expressions

share|improve this answer
Maybe too pedantic, but technically the "backtick" character is `. I think you mean "backslash" :) +1 for the useful help! – rinogo Nov 19 '15 at 22:14
You're right, that was simply a typo. Fixed. – slhck Nov 20 '15 at 8:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .