Reputation: 2921
I have the following text:
query([[
select *
from ]]..s_Schema..[[Table
where RowNumber = n_Counter
]],{Counter = n_Counter});
I need to find substring n_
that is between ([[
and ]],
.
Such a regexp: \(\[\[[.\r\n]+n_[.\r\n]+\]\],
doesn't work.
My case seems to be opposite to this one: Regular expressions: find string without substring
Or this: regex match substring unless another substring matches
Upvotes: 0
Views: 389
Reputation: 522181
A literal implementation of your requirement would be:
Find:
\(.*\[\[.*?(n_\w+).*\]\]
Your current regex has several problems, of which perhaps which stands out the most is this:
[.\r\n]
This character class doesn't do what you think; this will match one of the following three things: a literal dot, a carriage return, or a newline. The query code you are trying to match will never match to this.
Demo here:
Upvotes: 1
Reputation: 10199
Do a regular expression find like this:
\(\[\[\K.*(?=\]\],)
Explanation
\(\[\[\K
starts matching after [[
(?=\]\],)
is a Lookahead, it matches only if followed by ]],
Upvotes: 0