Reputation: 903
In my LaTeX
work I need to do Regex search with \|(.*?)\|
to capture |whatever|
and replace it with \somecommand{$1}
. But I do not want to capture ||
(That is, there is nothing between them.) How should I refine my regex search?
(By the way, what should my title be, so that it is useful for others?)
Upvotes: 0
Views: 26
Reputation: 163207
You have to change the asterix (which matches 0+ times) to a plus sign make the quantifier match at least 1 character.
\|(.+?)\|
^
Upvotes: 1
Reputation: 18357
Change your regex to,
\|[^|]+\|
OR
\|.+\|
If you want to also capture pipes in between searched content
Upvotes: 2