Created
June 29, 2012 11:07
-
-
Save Midnighter/3017372 to your computer and use it in GitHub Desktop.
Search and replace in Kile using non-greedy pattern matching.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
By example, I wanted to replace all inline math $...$ with \( ... \). So I had to match the (escaped) dollar sign \$ then put the text inbetween in a group (this is achieved by the parentheses). The brackets, in usual regex style, form a category of symbols. In this case every symbol but the dollar sign in order to simulate non-greedy matching. This is like using .+? in normal regular expressions. So the search pattern is: | |
\$([^\$]+)\$ | |
The group given by the parentheses can be referred to in the replacement by \1, so the replacement text is: | |
\\( \1 \\) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment